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

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 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.
Enforce a blank line between elements. There are three Enforce a blank line between elements. There are two exceptions
exceptions to this rule: to this rule:
1. Preserve blank lines between sibling items in a plain list, 1. Preserve blank lines between sibling items in a plain list,
2. Outside of plain lists, preserve blank lines between 2. In an item, remove any blank line before the very first
a paragraph and a plain list,
3. In an item, remove any blank line before the very first
paragraph and the next sub-list. 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 (e) (lambda (e)
(cond (org-element-put-property
((not (and (eq (org-element-type e) 'paragraph) e :post-blank
(eq (org-element-type (org-export-get-next-element e info)) (if (and (eq (org-element-type e) 'paragraph)
'plain-list))) (eq (org-element-type (org-element-property :parent e)) 'item)
(org-element-put-property e :post-blank 1)) (eq (org-element-type (org-export-get-next-element e info))
((not (eq (org-element-type (org-element-property :parent e)) 'item))) 'plain-list)
(t (org-element-put-property (not (org-export-get-previous-element e info)))
e :post-blank (if (org-export-get-previous-element e info) 1 0)))))) 0
1))))
;; Return updated tree. ;; Return updated tree.
tree) tree)