jrblevin / markdown-mode

Emacs Markdown Mode
http://jblevins.org/projects/markdown-mode/
GNU General Public License v3.0
892 stars 163 forks source link

export to .md with code blocks if source is an .org file #736

Open nbehrnd opened 1 year ago

nbehrnd commented 1 year ago

Expected Behavior

After writing an .org file in orgmode, I anticipated the export by C-c C-e m m would fence snippets of code including a keyword to label the language the snippets are about. As an example of the pattern imagined

``` python for i in range(5): print(i) ```

The manual describes C-c C-s C as a chord within markdown mode to «insert[s] a GFM style backquote fenced code block.» which in this form is not compatible within orgmode.

Actual Behavior

Running Emacs orgmode, the export by C-c C-e m m only yields

    for i in range(5):
        print(i)

without fencing back ticks prior / after, and without a label about the language in question. So far, I obtained the pattern wanted with pandoc, e.g. by

pandoc test.org -o test_org2md_pandoc.md   # Pandoc's markdown format
pandoc test.org -o test_org2md_pandoc_gfm.md -t gfm # GitHub flavoured markdown

Question/feature suggest

Is there an option to permit export of fenced snippets of code e.g., by an additional line (similar to +#OPTIONS: in the file's header) in the .org file?

Steps to Reproduce

I prepared an .org file (attached in the .zip below), test.org. It contains some text, a labeled snippet of Python, an other about Fortran. While running orgmode, I exported this document by C-c C-e m m to write file test.md (equally provided).

Software Versions

Based on a thread on the orgmode discussion board org-mode code fence for markdown I amended Emacs 27.1 as provided by Linux Debian 12/bookworm by elpa-markdown-mode (2.5-1)and elpa-markdown-toc (0.1.5-1) via the synaptic package manager.

2022-11-29_markdownmode_report.zip