From f7b76d5a78f5c033cc7f5aaa5c6b005e79849519 Mon Sep 17 00:00:00 2001 From: Takuya OBUCHI Date: Sat, 21 May 2016 03:56:56 +0900 Subject: [PATCH 1/2] Skip trimming newline in paragraph --- ox-gfm.el | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ox-gfm.el b/ox-gfm.el index c33269f..6c77a7d 100644 --- a/ox-gfm.el +++ b/ox-gfm.el @@ -73,14 +73,11 @@ "Transcode PARAGRAPH element into Github Flavoured Markdown format. CONTENTS is the paragraph contents. INFO is a plist used as a communication channel." - (let ((contents - (concat (mapconcat 'identity (split-string contents) " ") - "\n"))) - (let ((first-object (car (org-element-contents paragraph)))) - ;; If paragraph starts with a #, protect it. - (if (and (stringp first-object) (string-match "\\`#" first-object)) - (replace-regexp-in-string "\\`#" "\\#" contents nil t) - contents)))) + (let ((first-object (car (org-element-contents paragraph)))) + ;; If paragraph starts with a #, protect it. + (if (and (stringp first-object) (string-match "\\`#" first-object)) + (replace-regexp-in-string "\\`#" "\\#" contents nil t) + contents))) ;;;; Src Block From 2feeb57a8d3a6a1e89a1b07284a3ee8032dd4f06 Mon Sep 17 00:00:00 2001 From: Takuya OBUCHI Date: Sat, 21 May 2016 05:13:26 +0900 Subject: [PATCH 2/2] When preserve-breaks is set on, skip trimming newline in paragraph --- ox-gfm.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ox-gfm.el b/ox-gfm.el index 6c77a7d..a560eec 100644 --- a/ox-gfm.el +++ b/ox-gfm.el @@ -69,10 +69,13 @@ ;;;; Paragraph -(defun org-gfm-paragraph (paragraph contents _info) +(defun org-gfm-paragraph (paragraph contents info) "Transcode PARAGRAPH element into Github Flavoured Markdown format. CONTENTS is the paragraph contents. INFO is a plist used as a communication channel." + (unless (plist-get info :preserve-breaks) + (setq contents (concat (mapconcat 'identity (split-string contents) " ") + "\n"))) (let ((first-object (car (org-element-contents paragraph)))) ;; If paragraph starts with a #, protect it. (if (and (stringp first-object) (string-match "\\`#" first-object))