[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [PATCH] ox-md.el: enhance example/src blocks support
From: |
Lungang Fang |
Subject: |
[O] [PATCH] ox-md.el: enhance example/src blocks support |
Date: |
Wed, 14 Dec 2016 21:17:38 +1100 |
* 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)
- [O] [PATCH] ox-md.el: enhance example/src blocks support,
Lungang Fang <=