Pandoc: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 1: Line 1:
== Pandoc ==
[[File:pandoc_diagram.jpg|400px|right]]
[[File:pandoc_diagram.jpg|400px|right]]


Line 33: Line 32:


'''page.wiki''' - mediawiki input filename
'''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




[[Category:Cookbook]]
[[Category:Cookbook]]

Revision as of 16:10, 8 June 2020

Pandoc diagram.jpg

A universal document converter - converts from one markup language onto another

https://pandoc.org/

Use: convert downloaded wiki pages onto HTML files

extensive documentation in Pandoc’s Manual or man pandoc


pandoc example1: convert HTML string to markdown

echo "<h1>Hello Pandoc</h1><p>from html to markdown</p>" | pandoc -f html -t markdown

pandoc example2: 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


Pandoc common 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