diff options
author | Justin Gordon <justin.gordon@gmail.com> | 2014-01-21 23:35:34 +0100 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2014-01-21 23:39:23 +0100 |
commit | d91650b854e07b41cfeb26e0c4fbc2c20c71d8ae (patch) | |
tree | e1c9e7cb777b4b6f2c4136ad2acb2a07b9f6a9cb | |
parent | e5259962f61c398d84d43d33c29a6f021c9b326a (diff) | |
download | org-mode-d91650b854e07b41cfeb26e0c4fbc2c20c71d8ae.tar.gz |
ox-md: Set correctly blank lines between elements
* lisp/ox-md (org-md-separate-elements): Fix blank line insertion
between elements.
* lisp/ox-md.el (org-md-inner-template): New function.
-rw-r--r-- | lisp/ox-md.el | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/lisp/ox-md.el b/lisp/ox-md.el index c77a4bc..2ecafc8 100644 --- a/lisp/ox-md.el +++ b/lisp/ox-md.el @@ -77,6 +77,7 @@ This variable can be set to either `atx' or `setext'." (headline . org-md-headline) (horizontal-rule . org-md-horizontal-rule) (inline-src-block . org-md-verbatim) + (inner-template . org-md-inner-template) (italic . org-md-italic) (item . org-md-item) (line-break . org-md-line-break) @@ -96,19 +97,26 @@ This variable can be set to either `atx' or `setext'." ;;; Filters (defun org-md-separate-elements (tree backend info) - "Make sure elements are separated by at least one blank line. + "Fix blank lines between elements. TREE is the parse tree being exported. BACKEND is the export back-end used. INFO is a plist used as a communication channel. +Make sure there's no blank line before a plain list, unless it is +located right after a paragraph. Otherwise, add a blank line +between elements. Blank lines between items are preserved. + Assume BACKEND is `md'." - (org-element-map tree org-element-all-elements + (org-element-map tree (remq 'item org-element-all-elements) (lambda (elem) - (unless (eq (org-element-type elem) 'org-data) - (org-element-put-property - elem :post-blank - (let ((post-blank (org-element-property :post-blank elem))) - (if (not post-blank) 1 (max 1 post-blank))))))) + (org-element-put-property + elem :post-blank + (if (and (eq (org-element-type (org-export-get-next-element elem info)) + 'plain-list) + (not (and (eq (org-element-type elem) 'paragraph) + (org-export-get-previous-element elem info)))) + 0 + 1)))) ;; Return updated tree. tree) @@ -404,6 +412,14 @@ a communication channel." ;;;; Template +(defun org-md-inner-template (contents info) + "Return body of document after converting it to Markdown syntax. +CONTENTS is the transcoded contents string. INFO is a plist +holding export options." + ;; Make sure CONTENTS is separated from table of contents and + ;; footnotes with at least a blank line. + (org-trim (org-html-inner-template (concat "\n" contents "\n") info))) + (defun org-md-template (contents info) "Return complete document string after Markdown conversion. CONTENTS is the transcoded contents string. INFO is a plist used |