aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Brautaset <sbrautaset@laterpay.net>2016-02-25 18:36:10 +0000
committerStig Brautaset <sbrautaset@laterpay.net>2016-02-25 18:36:10 +0000
commit28a2001baee1f10a8de7b3d41a821666ed5ee1d9 (patch)
tree9b7bf14d63747f82ded669e97d098afd1918fa48
parentf92166883c28b51f1b30273e3add88fa2fb1ee39 (diff)
Support (very) simple headlines
-rw-r--r--ox-jira.el8
-rw-r--r--ox-jira.org18
-rw-r--r--test/ox-jira-test.el8
-rw-r--r--test/ox-jira-test.org14
4 files changed, 46 insertions, 2 deletions
diff --git a/ox-jira.el b/ox-jira.el
index b8a42dc..1bb4791 100644
--- a/ox-jira.el
+++ b/ox-jira.el
@@ -118,7 +118,13 @@ channel."
"Transcode a HEADLINE element from Org to JIRA.
CONTENTS is the contents of the headline, as a string. INFO is
the plist used as a communication channel."
- contents)
+ (let* ((level (org-export-get-relative-level headline info))
+ (title (org-export-data-with-backend
+ (org-element-property :title headline)
+ 'jira info)))
+ (concat
+ (format "h%d. %s\n" level title)
+ contents)))
(defun org-jira-italic (italic contents info)
"Transcode ITALIC from Org to JIRA.
diff --git a/ox-jira.org b/ox-jira.org
index dd18ae8..27ff453 100644
--- a/ox-jira.org
+++ b/ox-jira.org
@@ -231,12 +231,28 @@
**** Headline
+ Headlines are a little bit more complex. I'm not even attempting to
+ support TODO labels and meta-information, just the straight-up text. It
+ would be nice to support the six standard levels of headlines JIRA offers
+ though.
+
+ Since the headline level is _relative_ rather than absolute, if the
+ exporter sees a '** second level' heading before it's seen a '* first
+ level' then the '** second level' will think it's a top-level heading.
+ That's a bit weird, but there you go.
+
#+BEGIN_SRC emacs-lisp
(defun org-jira-headline (headline contents info)
"Transcode a HEADLINE element from Org to JIRA.
CONTENTS is the contents of the headline, as a string. INFO is
the plist used as a communication channel."
- contents)
+ (let* ((level (org-export-get-relative-level headline info))
+ (title (org-export-data-with-backend
+ (org-element-property :title headline)
+ 'jira info)))
+ (concat
+ (format "h%d. %s\n" level title)
+ contents)))
#+END_SRC
**** Italic
diff --git a/test/ox-jira-test.el b/test/ox-jira-test.el
index 99e8f00..f3f8717 100644
--- a/test/ox-jira-test.el
+++ b/test/ox-jira-test.el
@@ -61,6 +61,14 @@ This is a quote with _emphasis_.
This is a quote with /emphasis/.
#+end_quote" 'jira))))
+(ert-deftest ox-jira-test/headlines ()
+ (should (equal "h1. top level
+h2. second level
+h3. third level
+" (org-export-string-as "* top level
+** second level
+*** third level" 'jira))))
+
(provide 'ox-jira-test)
;;; ox-jira.el-test.el ends here
diff --git a/test/ox-jira-test.org b/test/ox-jira-test.org
index fc68824..cbbd189 100644
--- a/test/ox-jira-test.org
+++ b/test/ox-jira-test.org
@@ -124,6 +124,20 @@
,#+end_quote" 'jira))))
#+END_SRC
+*** Headlines
+
+ Headline numbering in org is _relative_, so we cannot test that they work one-by-one.
+
+ #+BEGIN_SRC emacs-lisp
+ (ert-deftest ox-jira-test/headlines ()
+ (should (equal "h1. top level
+ h2. second level
+ h3. third level
+ " (org-export-string-as "* top level
+ ,** second level
+ ,*** third level" 'jira))))
+ #+END_SRC
+
*** Provide
Announce that =ox-jira-test= is a feature of the current Emacs.