Pandoc: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
Line 11: Line 11:
==Pandoc common arguments==
==Pandoc common arguments==


'''-f''' - option standing for “from”, is followed by the input format;
'''-f''' - option standing for “from”, is followed by the input format


'''-t''' - option standing for “to”, is followed by the output 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;
'''-s''' - option standing for “standalone”, produces output with an appropriate header and footer


'''-o''' - option for file output;
'''-o''' - option for file output
 
'''page.wiki''' - mediawiki input filename


== changing the default template ==
== changing the default template ==

Revision as of 08:27, 3 October 2023

Pandoc diagram.jpg

https://pandoc.org/

You can use Pandoc to generate PDF's directly from other document formats, like Markdown, wikitext, Libre Office or PDF.

Pandoc is an universal document converter - converts from one markup language onto another

Extensive documentation: Pandoc’s Manual or man pandoc

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

changing the default template

$ pandoc --from markdown --to html --print-default-template=html5 > template.html
$ pandoc --from markdown --to html --template template.html input.md -o output.html

PDF

A range of PDF engines are supported at the moment, including Paged.js, weasyprint and LaTeX. You need to select the one of choice using the --pdf-engine option, and have the PDF engine installed on your computer.

You can follow this page for instructions: https://pandoc.org/MANUAL.html#creating-a-pdf

Examples

Convert HTML string to markdown

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

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