diff options
| author | Stig Brautaset <stig@brautaset.org> | 2016-02-26 07:57:39 +0000 |
|---|---|---|
| committer | Stig Brautaset <stig@brautaset.org> | 2016-02-26 07:59:53 +0000 |
| commit | 2103b5779e653a9cb383cfd88e3a56f480c6adfa (patch) | |
| tree | 30ed255187cf4f04254be2d913718e21f1c52a99 | |
| parent | 7701794469371efd3ca5317a9321814301c8f282 (diff) | |
Add support for source code blocks
| -rw-r--r-- | ox-jira.el | 11 | ||||
| -rw-r--r-- | ox-jira.org | 14 | ||||
| -rw-r--r-- | test/ox-jira-test.el | 11 | ||||
| -rw-r--r-- | test/ox-jira-test.org | 18 |
4 files changed, 52 insertions, 2 deletions
@@ -80,7 +80,7 @@ (radio-target . (lambda (&rest args) (org-jira--not-implemented 'radio-target))) (section . org-jira-section) (special-block . (lambda (&rest args) (org-jira--not-implemented 'special-block))) - (src-block . (lambda (&rest args) (org-jira--not-implemented 'src-block))) + (src-block . org-jira-src-block) (statistics-cookie . (lambda (&rest args) (org-jira--not-implemented 'statistics-cookie))) (strike-through . (lambda (&rest args) (org-jira--not-implemented 'strike-through))) (subscript . (lambda (&rest args) (org-jira--not-implemented 'subscript))) @@ -172,6 +172,15 @@ CONTENTS is the contents of the section, as a string. INFO is the plist used as a communication channel." contents) +(defun org-jira-src-block (src-block contents info) + "Transcode a SRC-BLOCK element from Org to Jira. +CONTENTS holds the contents of the item. INFO is a plist holding +contextual information." + (when (org-string-nw-p (org-element-property :value src-block)) + (let* ((lang (org-element-property :language src-block)) + (code (car (org-export-unravel-code src-block)))) + (format "{code:%s}\n%s{code}" lang code)))) + (defun org-jira-quote-block (quote-block contents info) "Transcode a QUOTE-BLOCK element from Org to Jira. CONTENTS holds the contents of the block. INFO is a plist diff --git a/ox-jira.org b/ox-jira.org index 45055a4..e80b404 100644 --- a/ox-jira.org +++ b/ox-jira.org @@ -168,7 +168,7 @@ (radio-target . (lambda (&rest args) (org-jira--not-implemented 'radio-target))) (section . org-jira-section) (special-block . (lambda (&rest args) (org-jira--not-implemented 'special-block))) - (src-block . (lambda (&rest args) (org-jira--not-implemented 'src-block))) + (src-block . org-jira-src-block) (statistics-cookie . (lambda (&rest args) (org-jira--not-implemented 'statistics-cookie))) (strike-through . (lambda (&rest args) (org-jira--not-implemented 'strike-through))) (subscript . (lambda (&rest args) (org-jira--not-implemented 'subscript))) @@ -347,6 +347,18 @@ contents) #+END_SRC +*** Source code block + + #+BEGIN_SRC emacs-lisp + (defun org-jira-src-block (src-block contents info) + "Transcode a SRC-BLOCK element from Org to Jira. + CONTENTS holds the contents of the item. INFO is a plist holding + contextual information." + (when (org-string-nw-p (org-element-property :value src-block)) + (let* ((lang (org-element-property :language src-block)) + (code (car (org-export-unravel-code src-block)))) + (format "{code:%s}\n%s{code}" lang code)))) + #+END_SRC *** Quote block #+BEGIN_SRC emacs-lisp diff --git a/test/ox-jira-test.el b/test/ox-jira-test.el index 314b743..07fc442 100644 --- a/test/ox-jira-test.el +++ b/test/ox-jira-test.el @@ -96,6 +96,17 @@ h3. third level 3. fa 3. fum" 'jira)))) +(ert-deftest ox-jira-test/src-blocks () + (should (equal "{code:sh} +echo hello +# echo world +{code} +" (org-export-string-as "#+begin_src sh + echo hello + # echo world + #+end_src +" '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 8f7d693..5752b0c 100644 --- a/test/ox-jira-test.org +++ b/test/ox-jira-test.org @@ -176,6 +176,24 @@ 3. fum" 'jira)))) #+END_SRC +** Source code + + I use Org mode for literate programming, and executable lab notes, so we + need to export source code. + + #+BEGIN_SRC emacs-lisp + (ert-deftest ox-jira-test/src-blocks () + (should (equal "{code:sh} + echo hello + # echo world + {code} + " (org-export-string-as "#+begin_src sh + echo hello + # echo world + ,#+end_src + " 'jira)))) + #+END_SRC + ** Provide Announce that =ox-jira-test= is a feature of the current Emacs. |
