How to I convery from asciidoc to Markdown format?

I have a bunch of asciidoc files in a folder. I have tried various tools like pandoc but they don’t have an option of converting from asciidoc to markdown.

  1. Accepted Answer

Accepted Answer

You’ll need to first convert asciidoc to XML format and then to Markdown. In other words,

asciidoc ---> XML ---> markdown

First, install asciidoc and pandoc:

brew install asciidoc pandoc

Next, convert asciidoc document to markdown

asciidoc -b docbook file.adoc

This will create file.xml in XML format.

If you want to convert all *.adoc in a folder to markdown, you can use the following loop to do the tric:

for i in *.adoc; do asciidoc -b docbook $i; done 

You can then use pandoc to convert the files to markdown format. For a single file, you would:

pandoc -f docbook -t markdown_strict file.xml -o

To convert all files in the folder to markdown, use the loop again.

for i in *.xml; do pandoc -f docbook -t markdown_gfm $i -o $; done

Clean up. If you don’t need asciidoc or pandoc anymore, you can clean them up:

brew uninstall asciidoc
brew uninstall pandoc  

Speak Your Mind