From: Lungang Fang <lungang.fang@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] ox-md.el: enhance example/src blocks support
Date: Wed, 14 Dec 2016 21:17:38 +1100 [thread overview]
Message-ID: <CAFfEE6Ofat_4Phy78=bcWPJ3YkGssyH4EGejomLvGJ8wpKM=_Q@mail.gmail.com> (raw)
* 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)
next reply other threads:[~2016-12-14 10:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-14 10:17 Lungang Fang [this message]
2016-12-14 12:22 ` [PATCH] ox-md.el: enhance example/src blocks support Nicolas Goaziou
2016-12-14 21:43 ` Lungang Fang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFfEE6Ofat_4Phy78=bcWPJ3YkGssyH4EGejomLvGJ8wpKM=_Q@mail.gmail.com' \
--to=lungang.fang@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).