Is there any way to convert markdown to asciidoc (or be able to produce the same HTML output)?
Asked Answered
R

5

25

Here is my problem, normally I convert asciidoc documents to HTML (or more precisely asciidoc --> docbook --> html) but here I've been given a markdown document.

I would like to be able to produce an HTML document from that markdown document that would look the same as if it was coming from an asciidoc OR be able to convert this markdown to asciidoc somehow?

Reticulation answered 6/9, 2011 at 17:12 Comment(0)
T
11

Try to use Pandoc to convert the markdown source to docbook xml.

From there, it should be possible to convert the docbook xml to html with the same technique as you used before for the asciidoc input, e.g. use the same xslt-translations for docbook->html.

Tussis answered 22/10, 2011 at 10:48 Comment(1)
The latest version of Pandoc (in the repo) allows for asciidoc <-> markdown transormations.Theodicy
M
44

To echo @akosma comment, pandoc does indeed have AsciiDoc support:

# Convert to AsciiDoc from Markdown:
$ pandoc -t asciidoc -f markdown file1.md > file1.txt

You can also go directly from Markdown to HTML:

$ pandoc -S -t html -f markdown file1.md > file1.html

(The -S just to produce nice curly quotes and other Smart typographical changes)

Manton answered 2/11, 2012 at 15:26 Comment(1)
I think it is kind of abandoned at this point unfortunately, e.g. it has some glaring bugs: github.com/jgm/pandoc/issues/4362Swollen
T
11

Try to use Pandoc to convert the markdown source to docbook xml.

From there, it should be possible to convert the docbook xml to html with the same technique as you used before for the asciidoc input, e.g. use the same xslt-translations for docbook->html.

Tussis answered 22/10, 2011 at 10:48 Comment(1)
The latest version of Pandoc (in the repo) allows for asciidoc <-> markdown transormations.Theodicy
P
3

In my experience, Pandoc doesn't convert a lot of documents correctly, so I've created my own converter, which can be found here.

It's a simple tool written in Java which has been successfully used to convert a lot of documents, including the manual from Geb.

Partridgeberry answered 25/6, 2015 at 10:46 Comment(1)
I have a quite extensive suite here github.com/bodiam/markdown-to-asciidoc/tree/master/src/test/… Run them on Pandoc, and all failings tests are issues.Partridgeberry
M
3

I'll throw another one into the mix. I've written a custom converter for Kramdown that converts Markdown to AsciiDoc.

https://github.com/opendevise/kramdown-asciidoc

The benefit of this library is that Kramdown is extremely good at parsing GitHub-flavored Markdown, which is likely the Markdown people are most interested converting from.

Meehan answered 11/1, 2016 at 11:26 Comment(1)
Speaking from experience as a technical writer and user of the package, kramdown-asciidoc is far more suited to converting Markdown to Asciidoc than Pandoc. If you're interested, I wrote a post on the package that gives a reasonably in-depth look at the package and how to use it: matthewsetter.com/…Convalesce
C
0

This is the best pandoc solution:

pandoc --atx-headers --verbose --wrap=none --toc --reference-links -s -f markdown -t asciidoc -o file.adoc README.md

The version I used is pandoc 2.11.0.4.

Courtnay answered 28/10, 2020 at 21:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.