aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Brautaset <stig@brautaset.org>2016-02-26 08:14:19 +0000
committerStig Brautaset <stig@brautaset.org>2016-02-26 08:14:19 +0000
commitcbd6b317980a63cdac8124499bab29dee8f0b0ae (patch)
treee8fef987cc44a4848dc8c0ed6fba529b8f6ce365
parent2103b5779e653a9cb383cfd88e3a56f480c6adfa (diff)
Add support for example blocks
-rw-r--r--ox-jira.el11
-rw-r--r--ox-jira.org18
-rw-r--r--test/ox-jira-test.el13
-rw-r--r--test/ox-jira-test.org22
4 files changed, 61 insertions, 3 deletions
diff --git a/ox-jira.el b/ox-jira.el
index 92013db..25ea6f8 100644
--- a/ox-jira.el
+++ b/ox-jira.el
@@ -50,6 +50,7 @@
(drawer . (lambda (&rest args) (org-jira--not-implemented 'drawer)))
(dynamic-block . (lambda (&rest args) (org-jira--not-implemented 'dynamic-block)))
(entity . (lambda (&rest args) (org-jira--not-implemented 'entity)))
+ (example-block . org-jira-example-block)
(export-block . (lambda (&rest args) (org-jira--not-implemented 'export-block)))
(export-snippet . (lambda (&rest args) (org-jira--not-implemented 'export-snippet)))
(final-output . (lambda (&rest args) (org-jira--not-implemented 'final-output)))
@@ -115,6 +116,14 @@ CONTENTS is nil. INFO is a plist used as a communication
channel."
(format "{{%s}}" (org-element-property :value code)))
+(defun org-jira-example-block (example-block contents info)
+ "Transcode an EXAMPLE-BLOCK element from Org to Jira.
+CONTENTS is nil. INFO is a plist holding contextual
+information."
+ (when (org-string-nw-p (org-element-property :value example-block))
+ (format "{noformat}\n%s{noformat}"
+ (org-export-format-code-default example-block info))))
+
(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
@@ -178,7 +187,7 @@ 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))))
+ (code (org-export-format-code-default src-block info)))
(format "{code:%s}\n%s{code}" lang code))))
(defun org-jira-quote-block (quote-block contents info)
diff --git a/ox-jira.org b/ox-jira.org
index e80b404..495fc2c 100644
--- a/ox-jira.org
+++ b/ox-jira.org
@@ -138,6 +138,7 @@
(drawer . (lambda (&rest args) (org-jira--not-implemented 'drawer)))
(dynamic-block . (lambda (&rest args) (org-jira--not-implemented 'dynamic-block)))
(entity . (lambda (&rest args) (org-jira--not-implemented 'entity)))
+ (example-block . org-jira-example-block)
(export-block . (lambda (&rest args) (org-jira--not-implemented 'export-block)))
(export-snippet . (lambda (&rest args) (org-jira--not-implemented 'export-snippet)))
(final-output . (lambda (&rest args) (org-jira--not-implemented 'final-output)))
@@ -229,6 +230,21 @@
(format "{{%s}}" (org-element-property :value code)))
#+END_SRC
+*** Example block
+
+ I often use this for log lines etc. Let's use the JIRA ={noformat}= tags
+ for it.
+
+ #+BEGIN_SRC emacs-lisp
+ (defun org-jira-example-block (example-block contents info)
+ "Transcode an EXAMPLE-BLOCK element from Org to Jira.
+ CONTENTS is nil. INFO is a plist holding contextual
+ information."
+ (when (org-string-nw-p (org-element-property :value example-block))
+ (format "{noformat}\n%s{noformat}"
+ (org-export-format-code-default example-block info))))
+ #+END_SRC
+
*** Headline
Headlines are a little bit more complex. I'm not even attempting to
@@ -356,7 +372,7 @@
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))))
+ (code (org-export-format-code-default src-block info)))
(format "{code:%s}\n%s{code}" lang code))))
#+END_SRC
*** Quote block
diff --git a/test/ox-jira-test.el b/test/ox-jira-test.el
index 07fc442..a8d250a 100644
--- a/test/ox-jira-test.el
+++ b/test/ox-jira-test.el
@@ -107,6 +107,19 @@ echo hello
#+end_src
" 'jira))))
+(ert-deftest ox-jira-test/example-blocks ()
+ (should (equal "{noformat}
+stuff that should
+ not be
+formatted
+{noformat}
+" (org-export-string-as "#+begin_example
+stuff that should
+ not be
+formatted
+#+end_example
+" '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 5752b0c..f54f7c2 100644
--- a/test/ox-jira-test.org
+++ b/test/ox-jira-test.org
@@ -191,7 +191,27 @@
echo hello
# echo world
,#+end_src
- " 'jira))))
+ " 'jira))))
+ #+END_SRC
+
+** Examples
+
+ I use example blocks for log & config file snippets, and output from
+ programs.
+
+ #+BEGIN_SRC emacs-lisp
+ (ert-deftest ox-jira-test/example-blocks ()
+ (should (equal "{noformat}
+ stuff that should
+ not be
+ formatted
+ {noformat}
+ " (org-export-string-as "#+begin_example
+ stuff that should
+ not be
+ formatted
+ ,#+end_example
+ " 'jira))))
#+END_SRC
** Provide