Pandoc - the Swiss Army Knife to convert Content
Pandoc is an “universal document converter”, with the ability to convert from multiple input formats (Markdown, reStructuredText, textile, HTML, DocBook, Microsoft Word docx, LibreOffice ODT, EPUB and many more) to even more output formats.
My primary usage of Pandoc is to generate nice looking template-based documents in Microsoft Word docx, HTML and EPUP from plaintext files written in Pandoc’s Markdown. As Markdown splits content from layout, you get consistent look and appearance across different documents, and you can customize output by using templates.
But also convert HTML to HTML is useful, to only keep structured text and apply own templates to the content.
Pandoc’s Markdown
Pandoc’s Markdown is an extended version of John Gruber’s Markdown syntax.
I really like the many possibilities it adds to the original Markdown.
Header1
=======
Header2
-------
# Header1
## Header2
### Header3
normal paragraph with **strong** text.
another paragraph with an [inline link](http://google.de) and
<http://another-link>.
* Listitem
* Listitem
* Listitem
1. Listitem1
2. Listitem2
simple table with header
------ ------- ------ -------
A B C D
A X C Y
+---------------+---------------+--------------------+
| grid | table | |
+===============+===============+====================+
| with support | for multiple | - block |
| | | - elements |
+---------------+---------------+--------------------+
| and other | markdown | **syntax support** |
+---------------+---------------+--------------------+
pipe | tables
--------|--------
that do | not have to be
correctly | aligned
but | do not support block elements
Pandoc’s Markdown supports different table formats, and most PowerShell Format-Table
Output renders
perfectly fine as a “simple table” in Pandoc’s Markdown - so the following would be directly usable als markdown content:
PS C:\Windows> Get-ChildItem | Format-Table Name, LastWriteTime, Mode
Name LastWriteTime Mode
---- ------------- ----
addins 18.03.2017 22:03:33 d-----
appcompat 05.05.2017 08:08:32 d-----
AppPatch 16.11.2017 01:13:19 d-----
AppReadiness 07.12.2017 10:47:44 d-----
assembly 03.01.2018 02:14:50 d-r-s-
bcastdvr 18.03.2017 22:03:33 d-----
Boot 18.03.2017 22:03:29 d-----
Branding 18.03.2017 22:03:29 d-----
With this compatibility, it is really easy to generate nice looking documents based on content generated by PowerShell. Only Tables with Rows that do not fit in one line could not directly used from PowerShell output
Usage examples
Markdown to Microsoft Word .docx
pandoc -o "outputfile.docx" --toc --reference-doc="C:\Users\demo\Documents\layout.docx" sourcefile.markdown
Markdown to EPUB eBook-Format
pandoc -o "outputfile.epub" -s --toc sourcefile.markdown
Markdown to HTML
pandoc -o "outputfile.html" -s -t html5 --toc --toc-depth=2 sourcefile.markdown
HTML to HTML
pandoc -o "outputfile.html" -s --toc --toc-depth=2 sourcefile.html
pandoc -o "outputfile2.html" -s http://thebackend.info/index.html
Installation
Installation with Chocolatey
choco install pandoc
Download and installation for Windows, macOS and Linux
Download Pandoc from pandoc.org/installing.html