From 82b0c50dde7a8fa2133d36c3d23ea11893462932 Mon Sep 17 00:00:00 2001 From: Stig Brautaset Date: Thu, 25 Feb 2016 22:57:49 +0000 Subject: Remove soft linebreaks so paragraphs render properly in JIRA --- ox-jira.el | 2 +- ox-jira.org | 10 +++++++++- test/ox-jira-test.el | 7 +++++++ test/ox-jira-test.org | 12 ++++++++++++ 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 @@ -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. -- cgit v1.2.3