Transform content with Pandoc

von

I work with authors, editors, translators and blog contributors a lot these days. What I experienced was, everybody sends me content in Word documents! I never thought Markdown would be still such an unfamiliar format to many writers. My editors want to show me their changes (even if), and MicroSoft Words “track changes” feature comes handy.

Tool alarm

Today, I consider penflip.com to organize my writing. However, each tool needs time to learn. Until I have decided to put Penflip into my tooling chain, I need to deal with a lot of Word. It could be worse: nobody sent me PowerPoint so far ;-).

Pandoc is a Haskell library for Linux/Mac which helps you transforming content. You need to use the command line to make it work. The list of transformations is just impressive.

To install it on a Mac, you need to open your terminal. Assuming you have Homebrew installed, you just type:

$> brew install pandoc

With that, Pandoc should be installed and available already. Then cd to your working directory and type:

pandoc -f docx -t markdown -s -o mydoc.md mydoc.docx

-f is like: “from docs”, the -t switch says “to markdown”. -s lets the output become “static”, which means no fragments. And finally you tell Pandoc to “-o” output the result to the mydoc.md document, instead of the cli.

The last argument is your input document.

If you have many documents to transform, you can create an alias to your bash. Just edit .profile and add:

funcWord2md() {
  echo $1;
  pandoc -f docx -t markdown -s -o $1.md $1
}
alias word2md=funcWord2md

Don’t forget you need to open a new Bash session to apply these changes, or do: source ~/.profile

Tags: #Pandoc #Word #Content Transformation, #Markdown

Newsletter

ABMELDEN