keyboard-keys Transforming Markdown to other formats with Pandoc

Pandoc makes it easy to convert between a variety of file formats, including Markdown and Word.

I have been experimenting extensively with Ollama and other artificial intelligence tools, and the answers to my prompts are always rendered in Markdown. I have Marktext on my Linux computer and MacDown on my MacBook Air, so I can easily copy and paste the output into either of those editors and save it as a Markdown file.

However, when I want to share those files with colleagues who are unfamiliar with Markdown, I need a way to convert those files into a format that’s easily accessible for them. My Markdown editors can only export the Markdown files as HTML or PDF.

That problem is easily solved with Pandoc, a great tool that anyone can install on Linux, MacOS, or Windows that easily converts Markdown into various formats.

Installing Pandoc

Easily install Pandoc on Linux with the following commands:

$ sudo dnf install pandoc

or:

$ sudo apt install pandoc

On MacOS, use Homebrew to easily install Pandoc by opening a terminal and entering the following command:

$ brew install pandoc

You can install Pandoc on Microsoft Windows using Chocolatey with the following command:

> choco install pandoc

Once the application is installed, it works very well from the command line.

Running Pandoc

I needed to convert a Markdown document to Word DOCX format so my Windows-using colleagues could easily read the output from the LLM I had been using. The Pandoc project maintains great documentation, so I used the documentation and the program’s man page on my Linux system to enter the following command:

$ pandoc -o ProposedLease.docx -f markdown -t docx LeaseReview.md

That command line converts the LeaseReview.md file from (-f) Markdown format to (-t) DOCX format, saving the output (-o) to ProposedLease.docx.

The conversion was flawless and occurred in a second or two. Your experience may vary based on CPU, RAM, and the length of the document converted. The Markdown file of our lease review was converted to ProposedLease.docx, which I could easily share with my colleagues using Microsoft Word.

If you are uncomfortable installing software on your computer or an unprivileged user in a corporate or educational setting, you can use Pandoc online. Pandoc is open source with a GNU GPL version 2 license. For more information about Pandoc, consult their website and examine all of the options the program provides.


This article is adapted from Effortlessly Transform Your Markdown Documents to Accessible Formats with Pandoc by Don Watkins, and is republished with permission from the author.