瀏覽代碼

Merge branch 'maint'

Nicolas Goaziou 10 年之前
父節點
當前提交
3a1fff1b22
共有 1 個文件被更改,包括 19 次插入12 次删除
  1. 19 12
      lisp/ox-md.el

+ 19 - 12
lisp/ox-md.el

@@ -104,21 +104,28 @@ 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.
 
-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.
+Enforce a blank line between elements.  There are three
+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
+     paragraph and the next sub-list.
 
 Assume BACKEND is `md'."
   (org-element-map tree (remq 'item org-element-all-elements)
-    (lambda (elem)
-      (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))))
+    (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))))))
   ;; Return updated tree.
   tree)