emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] md backend needs to add blank line before some lists
@ 2014-11-02 21:41 Charles C. Berry
  2014-11-02 22:15 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Charles C. Berry @ 2014-11-02 21:41 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: TEXT/PLAIN, Size: 705 bytes --]


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

[-- Attachment #2: ox-md.el patch --]
[-- Type: TEXT/PLAIN, Size: 1680 bytes --]

From 8e82dbb23109e2bf13281d3f929bdddb9096d13d Mon Sep 17 00:00:00 2001
From: chasberry <ccberry@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)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] md backend needs to add blank line before some lists
  2014-11-02 21:41 [PATCH] md backend needs to add blank line before some lists Charles C. Berry
@ 2014-11-02 22:15 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2014-11-02 22:15 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: emacs-orgmode

Hello,

"Charles C. Berry" <ccberry@ucsd.edu> writes:

> 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.

Thanks for your patch. I applied a different one, though. 

I find blank lines rules in Markdown very unclear.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-11-02 22:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-02 21:41 [PATCH] md backend needs to add blank line before some lists Charles C. Berry
2014-11-02 22:15 ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).