I’m gradually moving away from reStructuredText (RST) and I use more MarkDown(MD) to write generic documentation. In fact, I found myself using md files more and more and I really like the approach of focusing on content and let the tool generate a well formatted document according to the type needed.
If MarkDown doesn’t need much introduction the tool I’m using to convert .md is called Pandoc.
Pandoc is a universal document converter and from an MD file can generate multiple output format. It’s open-source and really simple to use.
With “Content-First” approach in mind I’ve decided to write a simple tool to automate the generation of multiple output format starting from a single markdown.
I wrote a batch file that I’ve linked on my desktop, whenever I need to export a MD in different format I just drag the markdown file over the batch script icon and it creates all the desired format.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
:: MD CONVERT :: ------------------------ :: Converts all MarkDowns files passed as arguments into different :: formats and saves them into a separate folder. :: :: AUTHOR: Paolo Frigo, paolofrigo@gmail.com :: https://www.scriptinglibrary.com :: :: REQUIREMENTS: :: pandoc (https://pandoc.org/) :: miktex for pdf conversion form LaTeX (https://miktex.org/) set list=docx html rst odt rtf epub pdf for %%x in (%*) do ( mkdir output mkdir output\\%%~nx for %%e in (%list%) do ( mkdir output\\_%%e pandoc %%x -o output/_%%e/%%~nx.%%e pandoc %%x -o output/%%~nx/%%~nx.%%e ) :: Keep a copy of the MarkDown File. mkdir output\\_md copy %%x output\_md\ copy %%x output\%%~nx\ ) |
This script is also available on github. I really hope you’ll find it useful. I’ll soon release a similar script in BaSH in case you’re using Mac or Linux.