Skip to content

Pandoc

It is an opensource software to convert markdown files to other files.

The official page is github https://github.com/jgm/pandoc

2. Installation

From the official website they have installers for different OS, visit: https://github.com/jgm/pandoc/releases/latest

For linux amd64, download the .deb and execute with right click “install with software manager”

3. Usage

Once installed we can use it via command line. We go to the folder that contains the markdown file (.md)

pandoc ./sourceMarkdownFile.md -f markdown -t docx -s -o outputWordfile.docx

Local execution images and media

The good thing about running locally is that if your document has referenced images it will find them and add them, which does not happen with online generators.

4. Using as docker image

Sometimes it is more convenient to use the docker image than to install pandoc locally.

For the use of pandoc in docker run mode, it is necessary to go to the folder where the document to be exported is and execute (if executed from another directory the images or relative references that the document may have will not be found):

docker run --rm \
       --volume "$(pwd):/data" \
       --user $(id -u):$(id -g) \
       pandoc/core myfile.md -f markdown -t docx -s -o myfile.docx

5. Pandoc Latex

By default the pandoc/core image does not include utilities to export to epub, pdf and other formats. Using the image https://hub.docker.com/r/pandoc/latex we can perform that conversion easily:

docker run --rm \
       --volume "$(pwd):/data" \
       --user $(id -u):$(id -g) \
       pandoc/latex dateFields.md -f markdown -t pdf -s -o dateFields.pdf