aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Brautaset <stig@brautaset.org>2016-02-29 06:34:07 +0000
committerStig Brautaset <stig@brautaset.org>2016-02-29 06:34:07 +0000
commit57f93ca2a60831f375c1ee09a54c5ca4e3b01a07 (patch)
tree8774fb5d0c88ec99b9852d7bf2444ec2c56d6564
parentc2a923fdd02962555a85ee4a7803cafbac8b7dfd (diff)
Protect [ and { in plain text
-rw-r--r--ox-jira.el14
-rw-r--r--ox-jira.org24
-rw-r--r--test/ox-jira-test.el4
-rw-r--r--test/ox-jira-test.org11
4 files changed, 46 insertions, 7 deletions
diff --git a/ox-jira.el b/ox-jira.el
index c8f6de8..7ac10fe 100644
--- a/ox-jira.el
+++ b/ox-jira.el
@@ -68,7 +68,7 @@
(paragraph . org-jira-paragraph)
(parse-tree . (lambda (&rest args) (org-jira--not-implemented 'parse-tree)))
(plain-list . org-jira-plain-list)
- (plain-text . (lambda (plain-text info) plain-text))
+ (plain-text . org-jira-plain-text)
(planning . (lambda (&rest args) (org-jira--not-implemented 'planning)))
(property-drawer . (lambda (&rest args) (org-jira--not-implemented 'property-drawer)))
(quote-block . org-jira-quote-block)
@@ -213,10 +213,18 @@ the plist used as a communication channel."
(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 is the text with plain-list markup. INFO is a plist holding
+contextual information."
contents)
+(defun org-jira-plain-text (text info)
+ "Transcode TEXT from Org to JIRA.
+TEXT is the string to transcode. INFO is a plist holding
+contextual information."
+ (replace-regexp-in-string "\\([[{]\\)"
+ '(lambda (p) (format "\\%s" p))
+ text))
+
(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 570cabc..c859ee9 100644
--- a/ox-jira.org
+++ b/ox-jira.org
@@ -160,7 +160,7 @@
(paragraph . org-jira-paragraph)
(parse-tree . (lambda (&rest args) (org-jira--not-implemented 'parse-tree)))
(plain-list . org-jira-plain-list)
- (plain-text . (lambda (plain-text info) plain-text))
+ (plain-text . org-jira-plain-text)
(planning . (lambda (&rest args) (org-jira--not-implemented 'planning)))
(property-drawer . (lambda (&rest args) (org-jira--not-implemented 'property-drawer)))
(quote-block . org-jira-quote-block)
@@ -410,11 +410,29 @@
#+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 is the text with plain-list markup. INFO is a plist holding
+ contextual information."
contents)
#+END_SRC
+*** Plain text
+
+ This is text with no markup, but we have to escape certain characters to
+ avoid tripping up JIRA. In particular:
+
+ - ={= :: Introduces macros
+ - =[= :: Introduces links
+
+ #+BEGIN_SRC emacs-lisp
+ (defun org-jira-plain-text (text info)
+ "Transcode TEXT from Org to JIRA.
+ TEXT is the string to transcode. INFO is a plist holding
+ contextual information."
+ (replace-regexp-in-string "\\([[{]\\)"
+ '(lambda (p) (format "\\\\%s" p))
+ text))
+ #+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 236915e..455a605 100644
--- a/test/ox-jira-test.el
+++ b/test/ox-jira-test.el
@@ -142,6 +142,10 @@ fum" 'jira))))
" (org-export-string-as "- fi :: fo
- fa :: fum" 'jira))))
+(ert-deftest ox-jira-test/plain-text ()
+ (should (equal "fi fo \\[fa] fum
+" (org-export-string-as "fi fo [fa] fum" 'jira))))
+
(ert-deftest ox-jira-test/src-blocks ()
(should (equal "{code:none}
echo hello
diff --git a/test/ox-jira-test.org b/test/ox-jira-test.org
index c0c5400..47595e6 100644
--- a/test/ox-jira-test.org
+++ b/test/ox-jira-test.org
@@ -255,6 +255,16 @@
- fa :: fum" 'jira))))
#+END_SRC
+** Plain text
+
+ Check that certain characters are escaped.
+
+ #+BEGIN_SRC emacs-lisp
+ (ert-deftest ox-jira-test/plain-text ()
+ (should (equal "fi fo \\[fa] fum
+ " (org-export-string-as "fi fo [fa] fum" 'jira))))
+ #+END_SRC
+
** Source code
I use Org mode for literate programming, and executable lab notes, so we
@@ -312,7 +322,6 @@
" 'jira))))
#+END_SRC
-
** Examples
I use example blocks for log & config file snippets, and output from