An efficient way to convert Markdown to a Word readable format

In my previous post I pointed to some of the advantages Markdown has for writing. However, sooner or later you arrive in a situation where you need your text in the .doc / .docx / .odt format. Obviously, you google how to convert it and you end up with the good old Pandoc. This program works great for converting almost any type of documents. But recently I discovered that there is more to it than just:

pandoc -o output_file.odt input_file.md

Here are two ways to spice it up. First, use the --smart argument which ensures that straight quotes are converted to curly quotes, two dashes to an en-dash etc. In other words, Pandoc will attempt to produce a typographically correct output. Similarly, the --normalize argument removes repeated spaces and makes other corrections.

Second, you can use the --reference-odt or --reference-docx arguments, depending on which format you want do convert into. This points Pandoc to a reference file whose styles should be applied to the converted text. It allows you to pre-define the formatting of headings, paragraphs and other parts of text so that you don’t have to do this manually after every conversion. All in all you would use:

pandoc --smart --normalize --reference-odt=file.odt -o output_file.odt input_file.md

Using plain text for writing gets a lot easier. You just need to define the styles once and Pandoc will take care of the rest for you. No wonder Pandoc is presented on its homepage as a swiss army knife for working with documents. You can even tell it to generate table of contents based on headings used in the text. The options are vast, just look into the manual man pandoc.

There are few more things I would like to note:

  • The Pandoc manual says that for best results, the style reference files should be generated by Pandoc in the first place.

  • Pandoc recognizes multimarkdown footnotes (for syntax, search for footnotes here) and converts them correctly, yay!

  • If you need to quickly convert Markdown to HTML or PDF, you can always use Dillinger, an online conversion tool.

  • There is also one other way to make the conversion without Pandoc, though I suspect there are less options than are offered by Pandoc.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s