Pandoc



Pandoc/PDF is a package for the Atom editor that makes it possible to use Pandoc directly from an editor pane to create a PDF, and to view that PDF in another Atom pane.

Pandoc
  • PandaDoc is #1 Proposal, Contract and Document solution by G2. Leaders in eSignatures. Save 12 hrs per week and decrease creation time by 65%.
  • Pandoc is is a document conversion tool that can be used for exactly this (and a lot of other things). With Pandoc you can convert Markdown documents to PDF, HTML, Words DOCX or many other formats. After installing Pandoc, you can simply run it from command line. Note: By default, Pandoc uses LaTeX to generate PDF documents.

It is not a preview package, because what you see is the final, high-quality PDF output.

Activated by keyboard shortcut (default Alt-P) or menu item, Pandoc/PDF inserts a toolbar into the active editor, processes the document with Pandoc, and shows the resulting PDF. By default, the document is reprocessed every time it is saved, but that can be deactivated and reprocessing triggered instead with the keyboard shortcut or a toolbar button.

Pandoc/PDF supports all of Pandoc's text-based input formats, including Pandoc's Markdown, reStructuredText, Textile, MediaWiki & DokuWiki markup, and DocBook. It supports PDF generation via Pandoc's latex, beamer, context, html, and ms output formats.

Pandoc is a command-line tool for converting files from one markup language to another. Markup languages use tags to annotate sections of a document. Commonly used markup languages include Markdown, ReStructuredText, HTML, LaTex, ePub, and Microsoft Word DOCX. Pandoc a general markup converter, written in Haskell. I use this for all of my lecture notes, letters, slides, and websites. CommonMark a spec for a rationalized version of Markdown and reference implementations in C, JavaScript (commonmark.js), and Haskell (commonmark-hs).

Installation and prerequisites

Install from Atom's Settings/Install dialog (search for pandoc-pdf) or via apm install pandoc-pdf.

Pandoc needs to be installed. For full functionality, version 2.9.1 or later is necessary.

Equation

At least one PDF engine needs to be installed:

  • Latexmk with pdfLaTeX, XeLaTeX, or LuaLaTeX (e.g. from TeX Live or MiKTeX)
  • ConTeXt with pdfTeX, XeTeX, or LuaTeX (e.g. from TeX Live)
  • wkhtmltopdf, WeasyPrint, or Prince
  • pdfroff (from GNU troff)

If you choose Latexmk, see the Pandoc documentation for a list of the LaTeX packages needed by the default template.

To view the generated PDF within Atom, the pdfjs-viewer package is recommended, but pdf-view-plus or pdf-view can be used, too.

If the input format is Pandoc's Markdown, using the language-markdown package with a supported syntax theme is recommended for writing, but this does not affect the functionality of Pandoc/PDF.

Settings

Pandoc/PDF has settings to choose the PDF engine, Pandoc template and defaults file, and configure input file extensions. For a detailed explanation, see the package settings dialog after installation.

Toolbar buttons

The toolbar contains the following buttons:

Process with Pandoc into PDF

Triggers reprocessing with Pandoc. Processing occurs in the background, and Pandoc's log messages are shown in the 'Pandoc log messages' dialog.

Toggle Pandoc log messages

Toggles an overlay dialog with shows the Pandoc call including command line arguments, Pandoc's log messages, and its exit code. The icon is animated during processing, and changes color if warning or error messages are found. If Pandoc aborts processing with an error, the dialog opens automatically.

Save generated PDF

Pandoc generates the PDF file in a temporary directory along with other files, and opens it from there. This button allows to save the PDF to a user-chosen directory.

Open local defaults file in Atom

Recent versions of Pandoc allow options to be specified in a YAML-format 'DefaultsFile'. Pandoc/PDF checks whether a file with the same name as the document but the extension .yaml is present in the document's directory, and if yes, passes it to Pandoc. This button creates/opens such a local defaults file in Atom.

Show intermediate files generated by Pandoc

Opens the temporary directory in the system file browser.

Show Pandoc/PDF settings

Opens the Pandoc/PDF package settings dialog.

Show Pandoc User's Guide

Opens https://pandoc.org/MANUAL.pdf within Atom for quick reference. Note that only a subset of Pandoc's capabilities are relevant for Pandoc/PDF.

This software is copyrighted © 2020 by Carsten Allefeld and released under the terms of the MIT license.

With Pandoc, it is possible to use a CSS stylesheet while converting Markdown to HTML.

This is the basic format of the command:

Assuming you have the custom CSS ready. If not, one possibility is to use a classless CSS stylesheet. I came accross MVP.css recently and liked how it looked.

To use MVP.css for documenting a project I’m working on, I had to make some modifications to Pandoc’s default HTML template. These are the steps I followed.

Pandoc

First, I saved the default template to a file:

And then, made the following changes in template.html:

  • Move TOC to a dropdown menu in site navigation
  • Add a button with a link to the project website
  • Update colour scheme using CSS variables and made some minor adjustments to styles
Http://www.pando.com/

After adding some YAML metadata 1 to README.md, I ran pandoc again with the modified template and CSS file to generate the final output:

Pandoc Tutorial

You can get the modified template, MVP.css, a Makefile, and input and output files from this repository on GitLab.

These links might be useful:

Nbconvert Failed: Pandoc Wasn't Found

  • Pandoc home page
  • Pandoc usage examples
  • Pandoc documentation on templates
  • I also like the Sakura stylesheet
  • More classless css stylesheets

Pandoc Download

  1. Otherwise these variables will need to be provided on the command line. ↩