Pandoc: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 3: Line 3:
You can use Pandoc to generate PDF's directly from other '''document formats''', like Markdown, wikitext, Libre Office or PDF.  
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
Pandoc is described as an "universal document converter": it '''converts documents''' from one markup language into another.


'''Extensive documentation''': [https://pandoc.org/MANUAL.html Pandoc’s Manual] or <code>man pandoc</code>
'''Extensive documentation''': [https://pandoc.org/MANUAL.html Pandoc’s Manual] or <code>man pandoc</code>

Revision as of 08:29, 3 October 2023

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 described as an "universal document converter": it converts documents from one markup language into 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 mediawiki to html:
pandoc page.wiki -f mediawiki -t html -o page.html




Pandoc diagram.jpg