Converting AsciiDoc to Markdown

Hey, passing quickly to drop this useful tip.

I just found this comfortable way of converting and working with Markdown files, and thought of sharing these two tips.

Converting from AsciiDoc to Markdown

The installation line below focus on osx users, but pandoc and asciidoc are also available for linux and windows.

  1. Install asciidoc and pandoc:
$ brew install asciidoc pandoc

2. Using asciidoc, generate an xml from your adoc file:

$ asciidoc -b docbook yourfile.adoc

On the directory now you have yourfile.adoc and yourfile.xml.

3. Using these files, generate the markdown file:

○ → pandoc -f docbook -t markdown_strict yourfile.xml -o yourfile.md

If you are getting line breaks after each x number of chars on the generated md file, then, use this command instead (worked well for me):

iconv -t utf-8 yourfile.xml | pandoc -f docbook -t markdown_strict --wrap=none | iconv -f utf-8 > yourfile.md

Congrats your doc is now in markdown style. Let’s validate the work.

Editing Markdown

A recent tool I started using and I enjoy a lot, is Typora. I’m using it for editing lots of Markdown files (i.e. GitHub readme files). It’s available for OS X, Linux and Windows. The editor is easy to use and enables writing in markdown super quick without having to memorize all the sintax.

Notice how editor feels natural when you can directly edit the resulting layout (with GitHub flavors).

Finally… Once you migrated your adoc file, just open the folder using Typora to double check the work and adjust details.


Credits to: https://tinyapps.org/blog/201701240700_convert_asciidoc_to_markdown.html


2 responses

  1. raviramaswamyyahoocom

    Good tip.. Thanks

  2. Kurt

    Great, exactly the solution to my problem.
    Thank you very much

    #!/bin/bash
    # Converting AsciiDoc to LibreOffice
    asciidoctor -b docbook $1
    pandoc -f docbook -t odt -o ${1%.adoc}.odt ${1%.adoc}.xml

Leave a Reply to raviramaswamyyahoocomCancel reply

Discover more from Karina Varela

Subscribe now to keep reading and get access to the full archive.

Continue reading