aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Brautaset <stig@brautaset.org>2016-02-25 22:57:49 +0000
committerStig Brautaset <stig@brautaset.org>2016-02-25 22:57:49 +0000
commit82b0c50dde7a8fa2133d36c3d23ea11893462932 (patch)
tree046b52433135939d6b3d44f1c8ea0ae14aa5658c
parent4a7d9d2aaac3801e6cfc751d8f88ec18d283dbbe (diff)
Remove soft linebreaks so paragraphs render properly in JIRA
-rw-r--r--ox-jira.el2
-rw-r--r--ox-jira.org10
-rw-r--r--test/ox-jira-test.el7
-rw-r--r--test/ox-jira-test.org12
4 files changed, 29 insertions, 2 deletions
diff --git a/ox-jira.el b/ox-jira.el
index 1bb4791..31bf523 100644
--- a/ox-jira.el
+++ b/ox-jira.el
@@ -148,7 +148,7 @@ channel."
"Transcode a PARAGRAPH element from Org to JIRA.
CONTENTS is the contents of the paragraph, as a string. INFO is
the plist used as a communication channel."
- contents)
+ (replace-regexp-in-string "\n[^\']" " " contents))
(defun org-jira-section (section contents info)
"Transcode a SECTION element from Org to JIRA.
diff --git a/ox-jira.org b/ox-jira.org
index d397da2..7c0d083 100644
--- a/ox-jira.org
+++ b/ox-jira.org
@@ -287,12 +287,20 @@
*** Paragraph
+ One of the most annoying things about JIRA markup is the way it doesn't
+ reflow text properly, so any linebreaks becomes hard linebreaks in the
+ rendered output. Let's fix that!
+
+ What we need to do is replace any _internal_ newlines (i.e. any not at the
+ end of the string) with a space. Regexes to the rescue! I used [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Regexp-Backslash.html#Regexp-Backslash][this
+ reference]] to help me with this function.
+
#+BEGIN_SRC emacs-lisp
(defun org-jira-paragraph (paragraph contents info)
"Transcode a PARAGRAPH element from Org to JIRA.
CONTENTS is the contents of the paragraph, as a string. INFO is
the plist used as a communication channel."
- contents)
+ (replace-regexp-in-string "\n[^\']" " " contents))
#+END_SRC
*** Section
diff --git a/test/ox-jira-test.el b/test/ox-jira-test.el
index f3f8717..5e1b83f 100644
--- a/test/ox-jira-test.el
+++ b/test/ox-jira-test.el
@@ -1,3 +1,4 @@
+
;;; ox-jira-test.el --- tests for ox-jira.el
;;; Author: Stig Brautaset <stig@brautaset.org>
@@ -69,6 +70,12 @@ h3. third level
** second level
*** third level" 'jira))))
+(ert-deftest ox-jira-test/paragraphs ()
+ (should (equal "fi fo fa fum\n" (org-export-string-as "fi
+,fo
+,fa
+,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 a97d24e..1694a01 100644
--- a/test/ox-jira-test.org
+++ b/test/ox-jira-test.org
@@ -138,6 +138,18 @@
,*** third level" 'jira))))
#+END_SRC
+** Paragraphs
+
+ Check that text in paragraphs does not have hard newlines.
+
+ #+BEGIN_SRC emacs-lisp
+ (ert-deftest ox-jira-test/paragraphs ()
+ (should (equal "fi fo fa fum\n" (org-export-string-as "fi
+ ,fo
+ ,fa
+ ,fum" 'jira))))
+ #+END_SRC
+
** Provide
Announce that =ox-jira-test= is a feature of the current Emacs.