diff options
| author | Stig Brautaset <stig@brautaset.org> | 2016-02-25 23:37:13 +0000 |
|---|---|---|
| committer | Stig Brautaset <stig@brautaset.org> | 2016-02-26 00:11:28 +0000 |
| commit | 7701794469371efd3ca5317a9321814301c8f282 (patch) | |
| tree | 41334b96859ee5158512cce7ca0437e53949bb87 | |
| parent | 1b930266274450f56dd7a961e9ab3202d622ebaa (diff) | |
Support single-level ordered and unordered lists
| -rw-r--r-- | ox-jira.el | 20 | ||||
| -rw-r--r-- | ox-jira.org | 34 | ||||
| -rw-r--r-- | test/ox-jira-test.el | 20 | ||||
| -rw-r--r-- | test/ox-jira-test.org | 28 |
4 files changed, 97 insertions, 5 deletions
@@ -1,3 +1,4 @@ + ;;; ox-jira.el --- an Org mode export backend for JIRA format ;;; Copyright (C) 2016 Stig Brautaset @@ -61,7 +62,7 @@ (inline-src-block . (lambda (&rest args) (org-jira--not-implemented 'inline-src-block))) (inlinetask . (lambda (&rest args) (org-jira--not-implemented 'inlinetask))) (italic . org-jira-italic) - (item . (lambda (&rest args) (org-jira--not-implemented 'item))) + (item . org-jira-item) (keyword . (lambda (&rest args) (org-jira--not-implemented 'keyword))) (latex-environment . (lambda (&rest args) (org-jira--not-implemented 'latex-environment))) (latex-fragment . (lambda (&rest args) (org-jira--not-implemented 'latex-fragment))) @@ -71,7 +72,7 @@ (options . (lambda (&rest args) (org-jira--not-implemented 'options))) (paragraph . org-jira-paragraph) (parse-tree . (lambda (&rest args) (org-jira--not-implemented 'parse-tree))) - (plain-list . (lambda (&rest args) (org-jira--not-implemented 'plain-list))) + (plain-list . org-jira-plain-list) (plain-text . (lambda (plain-text info) plain-text)) (planning . (lambda (&rest args) (org-jira--not-implemented 'planning))) (property-drawer . (lambda (&rest args) (org-jira--not-implemented 'property-drawer))) @@ -132,6 +133,15 @@ CONTENTS is the text with italic markup. INFO is a plist holding contextual information." (format "_%s_" contents)) +(defun org-jira-item (item contents info) + "Transcode ITEM from Org to JIRA. +CONTENTS is the text with item markup. INFO is a plist holding +contextual information." + (let* ((parent (org-element-property :parent item)) + (list-type (org-element-property :type parent))) + (format "%s %s" (if (eq list-type 'ordered) "#" "-") + contents))) + (defun org-jira-underline (underline contents info) "Transcode UNDERLINE from Org to JIRA. CONTENTS is the text with underline markup. INFO is a plist holding @@ -150,6 +160,12 @@ CONTENTS is the contents of the paragraph, as a string. INFO is the plist used as a communication channel." (replace-regexp-in-string "\n[^\']" " " contents)) +(defun org-jira-plain-list (plain-list contents info) + "Transcode PLAIN-LIST from Org to JIRA. + CONTENTS is the text with plain-list markup. INFO is a plist holding + contextual information." + contents) + (defun org-jira-section (section contents info) "Transcode a SECTION element from Org to JIRA. CONTENTS is the contents of the section, as a string. INFO is diff --git a/ox-jira.org b/ox-jira.org index c3c3602..45055a4 100644 --- a/ox-jira.org +++ b/ox-jira.org @@ -150,7 +150,7 @@ (inline-src-block . (lambda (&rest args) (org-jira--not-implemented 'inline-src-block))) (inlinetask . (lambda (&rest args) (org-jira--not-implemented 'inlinetask))) (italic . org-jira-italic) - (item . (lambda (&rest args) (org-jira--not-implemented 'item))) + (item . org-jira-item) (keyword . (lambda (&rest args) (org-jira--not-implemented 'keyword))) (latex-environment . (lambda (&rest args) (org-jira--not-implemented 'latex-environment))) (latex-fragment . (lambda (&rest args) (org-jira--not-implemented 'latex-fragment))) @@ -160,7 +160,7 @@ (options . (lambda (&rest args) (org-jira--not-implemented 'options))) (paragraph . org-jira-paragraph) (parse-tree . (lambda (&rest args) (org-jira--not-implemented 'parse-tree))) - (plain-list . (lambda (&rest args) (org-jira--not-implemented 'plain-list))) + (plain-list . org-jira-plain-list) (plain-text . (lambda (plain-text info) plain-text)) (planning . (lambda (&rest args) (org-jira--not-implemented 'planning))) (property-drawer . (lambda (&rest args) (org-jira--not-implemented 'property-drawer))) @@ -265,6 +265,22 @@ (format "_%s_" contents)) #+END_SRC +*** Item + + A list item. This could be bullets, or numeric. This can get quite + complex. We might not handle every case... + + #+BEGIN_SRC emacs-lisp + (defun org-jira-item (item contents info) + "Transcode ITEM from Org to JIRA. + CONTENTS is the text with item markup. INFO is a plist holding + contextual information." + (let* ((parent (org-element-property :parent item)) + (list-type (org-element-property :type parent))) + (format "%s %s" (if (eq list-type 'ordered) "#" "-") + contents))) + #+END_SRC + *** Underline #+BEGIN_SRC emacs-lisp @@ -303,6 +319,20 @@ (replace-regexp-in-string "\n[^\']" " " contents)) #+END_SRC +*** Plain lists + + I make a lot of lists. Let's make sure we handle them! This is very + simple, as in the JIRA format all the logic is actually _for each item_ in + the list. + + #+BEGIN_SRC emacs-lisp + (defun org-jira-plain-list (plain-list contents info) + "Transcode PLAIN-LIST from Org to JIRA. + CONTENTS is the text with plain-list markup. INFO is a plist holding + contextual information." + contents) + #+END_SRC + *** Section Paragraphs are grouped into sections. I've not found any mention in the diff --git a/test/ox-jira-test.el b/test/ox-jira-test.el index 5e1b83f..314b743 100644 --- a/test/ox-jira-test.el +++ b/test/ox-jira-test.el @@ -76,6 +76,26 @@ h3. third level ,fa ,fum" 'jira)))) +(ert-deftest ox-jira-test/unordered-lists() + (should (equal "- fi +- fo +- fa +- fum +" (org-export-string-as "- fi +- fo +- fa +- fum" 'jira)))) + +(ert-deftest ox-jira-test/ordered-lists() + (should (equal "# fi +# fo +# fa +# fum +" (org-export-string-as "1. fi +2. fo +3. fa +3. fum" '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 1694a01..8f7d693 100644 --- a/test/ox-jira-test.org +++ b/test/ox-jira-test.org @@ -1,4 +1,4 @@ -#+TITLE: ox-jira-test +#+TITLE: Tests for JIRA Org export backend #+AUTHOR: Stig Brautaset #+PROPERTY: header-args:emacs-lisp :tangle yes :results silent * Introduction @@ -150,6 +150,32 @@ ,fum" 'jira)))) #+END_SRC +** Plain lists + + I like to use lists, so check that we handle them! + + #+BEGIN_SRC emacs-lisp + (ert-deftest ox-jira-test/unordered-lists() + (should (equal "- fi + - fo + - fa + - fum + " (org-export-string-as "- fi + - fo + - fa + - fum" 'jira)))) + + (ert-deftest ox-jira-test/ordered-lists() + (should (equal "# fi + # fo + # fa + # fum + " (org-export-string-as "1. fi + 2. fo + 3. fa + 3. fum" 'jira)))) + #+END_SRC + ** Provide Announce that =ox-jira-test= is a feature of the current Emacs. |
