Having got fed-up writing long documents in Word, I switched to using the text editor Notepad++ instead. Unfortunately, this means I was left with the task of formatting the final text in Word before I could distribute it. Then if there were amendments to make, I would end up doing them in Word to avoid having to do the formatting again.
There had to be a better way! I only need a few basic formatting features like headings, bullets and the odd link. If only I could use some simple mark-up and then convert to Word automatically.
After some Googling I found Markdown, a way to write in plain text with simple formatting. Couple this with Pandoc and a plain text file can be converted directly into a neatly formatted Word DOCX file.
Here’s the command I use to do the conversion:
pandoc input.txt -f markdown -t docx -s -o output.docx
One point to note is that the text file needs to be saved in UTF-8 encoding as that as what Pandoc expects.
Even better, you can get Pandoc to generate a blank DOCX template for you, and then customise it with your own styles, footers and page size etc. Then add the name of the template to the end of the command line like this:
pandoc input.txt -f markdown -t docx -s -o output.docx --reference-docx=template.docx
I can now do all my editing in Notepad++ and convert to a Word document at the last minute. Joy!
Here’s a handy page with a Markdown Cheatsheet.