We ❤️ Open Source

A community education resource

3 min read

Seamlessly convert Markdown documents to Office formats with Pandoc: A how-to guide

Harness the power of Pandoc to convert documents using this tutorial.

I have been experimenting a lot with Ollama and other artificial intelligence tools. The answers to my prompts are always rendered in Markdown, which is useful. 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 on my computer.

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.

Read more: Enhance your writing skills with Ollama and Phi3

Enhance your documentation workflow with Pandoc

That problem is easily solved with Pandoc which is a great tool that anyone can install on Linux, MacOS, or Windows that easily converts Markdown into any number of different formats. Easily install Pandoc on Linux with the following commands:

$ sudo apt 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. The project maintains great documentation. I needed to convert a Markdown document to .docx so my Windows using colleagues could easily read the output from the Large Language Model (LLM) I’ve been using. I used the documentation and the programs man page on my Linux system to enter the following command.

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

The conversion was flawless and occurred in a second or two. Your experience may vary based on CPU, RAM and 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 who were using Microsoft Word.

If you are a person who is uncomfortable installing software on your computer or you are an unpriviledged user in a corporate or educational setting you can use Pandoc online. Pandooc is open source with a GPL v2 license. For more information about Pandoc be sure to consult their website and examine all of the options that the program provides you.

More from We Love Open Source

This article is adapted from “Seamlessly convert your Markdown docs to Office formats using Pandoc” by Don Watkins, and is republished with permission from the author.

About the Author

I am Don Watkins, a free and open source software (FOSS) advocate.

Read Don's Full Bio

The opinions expressed on this website are those of each author, not of the author's employer or All Things Open/We Love Open Source.

Contribute to We ❤️ Open Source

Help educate our community by contributing a blog post, tutorial, or how-to.

Register for All Things Open 2024

Join thousands of open source friends October 27-29 in downtown Raleigh for ATO 2024!

Open Source Meetups

We host some of the most active open source meetups in the U.S. Get more info and RSVP to an upcoming event.