Merge pull request #9 from tkyobc/master

When preserve-breaks is set on, skip trimming newline in paragraph
This commit is contained in:
Lars Tveito 2016-05-20 23:42:29 +02:00
commit 66bed0d179

View File

@ -69,18 +69,18 @@
;;;; Paragraph ;;;; Paragraph
(defun org-gfm-paragraph (paragraph contents _info) (defun org-gfm-paragraph (paragraph contents info)
"Transcode PARAGRAPH element into Github Flavoured Markdown format. "Transcode PARAGRAPH element into Github Flavoured Markdown format.
CONTENTS is the paragraph contents. INFO is a plist used as a CONTENTS is the paragraph contents. INFO is a plist used as a
communication channel." communication channel."
(let ((contents (unless (plist-get info :preserve-breaks)
(concat (mapconcat 'identity (split-string contents) " ") (setq contents (concat (mapconcat 'identity (split-string contents) " ")
"\n"))) "\n")))
(let ((first-object (car (org-element-contents paragraph)))) (let ((first-object (car (org-element-contents paragraph))))
;; If paragraph starts with a #, protect it. ;; If paragraph starts with a #, protect it.
(if (and (stringp first-object) (string-match "\\`#" first-object)) (if (and (stringp first-object) (string-match "\\`#" first-object))
(replace-regexp-in-string "\\`#" "\\#" contents nil t) (replace-regexp-in-string "\\`#" "\\#" contents nil t)
contents)))) contents)))
;;;; Src Block ;;;; Src Block