From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lungang Fang Subject: [PATCH] ox-md.el: enhance example/src blocks support Date: Wed, 14 Dec 2016 21:17:38 +1100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cH6eP-00050o-KI for emacs-orgmode@gnu.org; Wed, 14 Dec 2016 05:19:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cH6eM-00026C-F2 for emacs-orgmode@gnu.org; Wed, 14 Dec 2016 05:19:05 -0500 Received: from mail-qt0-f169.google.com ([209.85.216.169]:35456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cH6eM-0001yU-9c for emacs-orgmode@gnu.org; Wed, 14 Dec 2016 05:19:02 -0500 Received: by mail-qt0-f169.google.com with SMTP id c47so14170102qtc.2 for ; Wed, 14 Dec 2016 02:18:39 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org * lisp/ox-md.el (org-md-example-block): Use "```" instead of 4-whitespace indentation for example/src blocks. The 4-whitespace has difficulty handling blocks under list items. The new code also allows syntax highlights for Programming languages The following org mode snippet is a test input: - Python src block within a list item #+BEGIN_SRC python for each in collection.find(): count += 1 print "Total number:", count #+END_SRC #+BEGIN_EXAMPLE OOPS! This is a first level example block #+END_EXAMPLE Output of the old version of org-md-example-block does not show as expected in Salsforce case editor or MacDown (http://macdown.uranusjr.com). In comparsion, it is coverted to the following by the new version and is handled by Salsforce and MacDown as expected: - Python src block within a list item ```python for each in collection.find(): count += 1 print "Total number:", count ``` ``` OOPS! This is a first level example block ``` TINYCHANGE --- lisp/ox-md.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lisp/ox-md.el b/lisp/ox-md.el index b8c4704..a176a8f 100644 --- a/lisp/ox-md.el +++ b/lisp/ox-md.el @@ -181,10 +181,11 @@ channel." "Transcode EXAMPLE-BLOCK element into Markdown format. CONTENTS is nil. INFO is a plist used as a communication channel." - (replace-regexp-in-string - "^" " " - (org-remove-indentation - (org-export-format-code-default example-block info)))) + (concat + "```" (org-element-property :language example-block) + "\n" + (org-export-format-code-default example-block info) + "```")) (defun org-md-export-block (export-block contents info) "Transcode a EXPORT-BLOCK element from Org to Markdown. -- 2.9.3 (Apple Git-75)