forked from mirrors/org-mode
ox-md: Fix blank lines in output
* lisp/ox-md.el (org-md-separate-elements): Outside of lists, preserve blank lines between paragraphs and plain lists. For example Consider this list: - three - four should become # Another test<a id="sec-2"></a> Consider this list: - three - four Thanks to Rafael for reporting it. http://permalink.gmane.org/gmane.emacs.orgmode/89840
This commit is contained in:
parent
c1bc685500
commit
3fed03941a
|
@ -102,21 +102,28 @@ This variable can be set to either `atx' or `setext'."
|
||||||
TREE is the parse tree being exported. BACKEND is the export
|
TREE is the parse tree being exported. BACKEND is the export
|
||||||
back-end used. INFO is a plist used as a communication channel.
|
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
|
Enforce a blank line between elements. There are three
|
||||||
located right after a paragraph. Otherwise, add a blank line
|
exceptions to this rule:
|
||||||
between elements. Blank lines between items are preserved.
|
|
||||||
|
1. Preserve blank lines between sibling items in a plain list,
|
||||||
|
|
||||||
|
2. Outside of plain lists, preserve blank lines between
|
||||||
|
a paragraph and a plain list,
|
||||||
|
|
||||||
|
3. In an item, remove any blank line before the very first
|
||||||
|
paragraph and the next sub-list.
|
||||||
|
|
||||||
Assume BACKEND is `md'."
|
Assume BACKEND is `md'."
|
||||||
(org-element-map tree (remq 'item org-element-all-elements)
|
(org-element-map tree (remq 'item org-element-all-elements)
|
||||||
(lambda (elem)
|
(lambda (e)
|
||||||
(org-element-put-property
|
(cond
|
||||||
elem :post-blank
|
((not (and (eq (org-element-type e) 'paragraph)
|
||||||
(if (and (eq (org-element-type (org-export-get-next-element elem info))
|
(eq (org-element-type (org-export-get-next-element e info))
|
||||||
'plain-list)
|
'plain-list)))
|
||||||
(not (and (eq (org-element-type elem) 'paragraph)
|
(org-element-put-property e :post-blank 1))
|
||||||
(org-export-get-previous-element elem info))))
|
((not (eq (org-element-type (org-element-property :parent e)) 'item)))
|
||||||
0
|
(t (org-element-put-property
|
||||||
1))))
|
e :post-blank (if (org-export-get-previous-element e info) 1 0))))))
|
||||||
;; Return updated tree.
|
;; Return updated tree.
|
||||||
tree)
|
tree)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue