ox-md: Enforce blank line between paragraph and plain list

* lisp/ox-md.el (org-md-separate-elements): Enforce blank line between
  paragraph and plain list.

Suggested-by: Charles C. Berry <ccberry@ucsd.edu>
<http://permalink.gmane.org/gmane.emacs.orgmode/92321>
This commit is contained in:
Nicolas Goaziou 2014-11-02 23:09:48 +01:00
parent cdb0a962bc
commit b26616091d
1 changed files with 12 additions and 14 deletions

View File

@ -102,28 +102,26 @@ This variable can be set to either `atx' or `setext'."
TREE is the parse tree being exported. BACKEND is the export
back-end used. INFO is a plist used as a communication channel.
Enforce a blank line between elements. There are three
exceptions to this rule:
Enforce a blank line between elements. There are two exceptions
to this rule:
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
2. In an item, remove any blank line before the very first
paragraph and the next sub-list.
Assume BACKEND is `md'."
(org-element-map tree (remq 'item org-element-all-elements)
(lambda (e)
(cond
((not (and (eq (org-element-type e) 'paragraph)
(eq (org-element-type (org-export-get-next-element e info))
'plain-list)))
(org-element-put-property e :post-blank 1))
((not (eq (org-element-type (org-element-property :parent e)) 'item)))
(t (org-element-put-property
e :post-blank (if (org-export-get-previous-element e info) 1 0))))))
(org-element-put-property
e :post-blank
(if (and (eq (org-element-type e) 'paragraph)
(eq (org-element-type (org-element-property :parent e)) 'item)
(eq (org-element-type (org-export-get-next-element e info))
'plain-list)
(not (org-export-get-previous-element e info)))
0
1))))
;; Return updated tree.
tree)