Convert text documents with Pandoc
Revision as of 14:33, 6 October 2021 by Simon (talk | contribs) (Simon moved page Convert downloaded wiki pages to HTML files with pandoc to Convert downloaded wiki pages to HTML files with Pandoc)
pandoc is a "universal document converter" which converts from one markup language to another.
In this guide, we try converting downloaded wiki pages (plain text in the .wiki format) to HTML files.
More extensive documentation is available at Pandoc’s Manual or through the command line by typing
man pandoc
Example 1: Convert an HTML string to Markdown
echo "<h1>Hello Pandoc</h1><p>from html to markdown</p>" | pandoc -f html -t markdown
Example 2: Convert a mediawiki file to HTML
- Save the content of a wiki page on to a plain-text file, example:
page.wiki
- convert:
pandoc page.wiki -f mediawiki -t html -o page.html
Common pandoc arguments
-f - option standing for “from”, is followed by the input format;
-t - option standing for “to”, is followed by the output format;
-s - option standing for “standalone”, produces output with an appropriate header and footer;
-o - option for file output;
page.wiki - mediawiki input filename
Changing the default template
pandoc --from markdown --to html5 --print-default-template=html5 > template.html pandoc --from markdown --to html5 --template template.html input.md -o output.html