Convert documents with Pandoc

Use Pandoc (https://pandoc.org) when you need to convert a file from one markup format into another. It can convert between many document formats, including Word documents (docx) to html or the other way around.

It’s easy to install and use, I have used in on Windows and Linux (Ubuntu 18.04), and is very well documented. On Windows, I installed it using the installer on https://pandoc.org/installing.html. On Ubuntu I installed it using

sudo apt install pandoc

Note that the version in the package manager most likely not is the latest release. Newest release can be found on https://github.com/jgm/pandoc/releases/latest.

Some usage examples.

Convert markdown to html:

pandoc pandoctest.md -f markdown -t html -s -o test1.html
[WARNING] This document format requires a nonempty  element.
Defaulting to ‘pandoctest’ as the title.
To specify a title, use ‘title’ in metadata or --metadata title=”…”.

I’m getting the warning since my pandoctest.md file didn’t have a title specified.

pandoctest.md is the source file to convert. -f markdown is source file format. -t html is target file format. -s option says to create a “standalone” complete document with a header and footer, not just a fragment. -o test1.html is the target file.

Convert Word to html:

pandoc pandoctest.docx -f markdown -t html -s -o test2.html

No warning here, since the Word document contained a title.

See many more examples on https://pandoc.org/demos.html.

Comments are closed.