Function: org-md-separate-elements

org-md-separate-elements is a byte-compiled function defined in ox-md.el.gz.

Signature

(org-md-separate-elements TREE BACKEND INFO)

Documentation

Fix blank lines between elements.

TREE is the parse tree being exported. BACKEND is the export backend used. INFO is a plist used as a communication channel.

Enforce a blank line between elements. There are exceptions to this rule:

  1. Preserve blank lines between sibling items in a plain list,

  2. In an item, remove any blank line before the very first
     paragraph and the next sub-list when the latter ends the
     current item.

  3. Do not add blank lines after table rows. (This is irrelevant for
     md exporter, but may surprise derived backends).

Assume BACKEND is md.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-md.el.gz
;;; Filters

(defun org-md-separate-elements (tree _backend info)
  "Fix blank lines between elements.

TREE is the parse tree being exported.  BACKEND is the export
backend used.  INFO is a plist used as a communication channel.

Enforce a blank line between elements.  There are exceptions to this
rule:

  1. Preserve blank lines between sibling items in a plain list,

  2. In an item, remove any blank line before the very first
     paragraph and the next sub-list when the latter ends the
     current item.

  3. Do not add blank lines after table rows.  (This is irrelevant for
     md exporter, but may surprise derived backends).

Assume BACKEND is `md'."
  (org-element-map tree
      (remq 'table-row (remq 'item org-element-all-elements))
    (lambda (e)
      (org-element-put-property
       e :post-blank
       (if (and (org-element-type-p e 'paragraph)
		(org-element-type-p (org-element-parent e) 'item)
		(org-export-first-sibling-p e info)
		(let ((next (org-export-get-next-element e info)))
		  (and (org-element-type-p next 'plain-list)
		       (not (org-export-get-next-element next info)))))
	   0
	 1))))
  ;; Return updated tree.
  tree)