Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Pandoc

📅 2022-Sep-16 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ pandoc ⬩ 📚 Archive

Pandoc is a commandline tool written in Haskell that can convert between different markup formats. For example, I write the pages of this blog in Markdown and convert them to HTML pages using Pandoc.

For detailed information about Pandoc commandline options please see man pandoc or the online manual.

$ pandoc in.markdown -o out.html
$ pandoc --from=markdown in.markdown -o out.html
$ pandoc --to=html5 in.markdown -o out.html
$ pandoc --shift-heading-level-by=1 in.markdown -o out.html
$ pandoc --title-prefix="Foobar" in.markdown -o out.html

This makes the title of the page as Foobar -- Actual title.

$ pandoc --template=foobar.template in.markdown -o out.html

There is a default output template that is used for each output format and can be seen by using the --print-default-template option. This default template can be used as a starting point to create your own templates.

$ pandoc --variable="date:2015-Jan-23" --template=foobar.template in.markdown -o out.html

We are specifying a variable of name date and value 2015-Jan-23 here.

$ pandoc --css=foobar.css in.markdown -o out.html
$ pandoc --include-in-header=header.txt in.markdown -o out.html

I find this useful for including the analytics JS code in the HTML header for example.

$ pandoc --include-before-body=header.html in.markdown -o out.html
$ pandoc --include-after-body=header.markdown in.markdown -o out.html
$ pandoc --from=markdown+gfm_auto_identifiers+autolink_bare_uris in.markdown -o out.html

Information on the extensions can be found in the Pandoc manual.

Tried with: Pandoc 2.9.2.1 and Ubuntu 22.04


© 2023 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 Mastodon📧 Email