John Hendy pointed out [1] that

list
- item1
- item2

Isn't the same as this:

list

- item1
- item2

when exported using the `md' backend (or its derivatives). But it needs to be to generate a proper document (at least with engines like pandoc.)

The attached patch enables this by adding a blank line after a `paragraph', but before a `plain-list' as long as the `paragraph' is not itself inside a list.

In other words, with the patch, the `md' export renders both lists with a blank line after the preceeding paragraph.

HTH,

Chuck

p.s. I have assigned copyright to FSF as `Charles Chester Berry' on Sept 23, 2014 (RT: 945490).

Footnote [1]: http://thread.gmane.org/gmane.emacs.orgmode/92289
From 8e82dbb23109e2bf13281d3f929bdddb9096d13d Mon Sep 17 00:00:00 2001
From: chasberry <ccbe...@ucsd.edu>
Date: Sun, 2 Nov 2014 13:16:55 -0800
Subject: [PATCH] lisp/ox-md.el: Fix lists following paragraphs

* lisp/ox-md.el (org-md-separate-elements): Add a line after a
  paragraph that preceeds a list, but is not itself contained in a
  list.

  Markdown needs a blank line following a paragraph to understand that
  a list really is a list. However, nested lists do not need this and
  adding the blank line would result in extra whitespace when
  formatted for display.
---
 lisp/ox-md.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index 9625948..fd950d2 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -110,7 +110,7 @@ exceptions to this rule:
 
   1. Preserve blank lines between sibling items in a plain list,
 
-  2. Outside of plain lists, preserve blank lines between
+  2. Outside of plain lists, preserve or add blank lines between
      a paragraph and a plain list,
 
   3. In an item, remove any blank line before the very first
@@ -127,6 +127,13 @@ Assume BACKEND is `md'."
        ((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-map tree 'paragraph
+    (lambda (e)
+      (if
+         (eq (org-element-type (org-export-get-next-element e info))
+             'plain-list)
+         (org-element-put-property e :post-blank 1)))
+    nil nil 'plain-list)
   ;; Return updated tree.
   tree)
 
-- 
1.9.3 (Apple Git-50)

Reply via email to