Using Atom, I'm trying to generate a PDF file from markdown.
I installed markdown-preview-plus
plugin, which supports pandoc, and then installed pandoc and configured the plugin to use it.
Now, markdown-preview-plus
does recognize pandoc, but I cannot see any command to generate a PDF. Plugin's web page seems to say nothing about that.. Can you help me?
Atom's markdown-preview-plus
package generates an HTML preview, as @mb21 alluded to. This is clear by the fact that you can right click on the preview and select Copy as HTML. With the Enable Pandoc Parser
option enabled, MPP is indeed using pandoc to generate this HTML preview.
In light of your question, I tried adding the following to the Pandoc Options: Commandline Arguments
setting in MPP:
--to=latex, --output=temp.pdf
Note 1: you can't specify --to=pdf
because pandoc can only generate PDF by first generating a LaTeX file.
Note 2: the above doesn't work because MPP essentially passes the contents of the editor window through pandoc 'on-the-fly', so you can't really hijack the --output
setting.
AFAIK, there is no way to get a "live" PDF preview (the way you can get a "live" HTML preview using MPP). This means you will have to build the document whenever you'd like to view what's changed.
Assuming you want to view the PDF in the Atom window, you can install pdf-view
and open the PDF in a pane, side-by-side with your source. Otherwise, you could simply open the PDF in your favorite PDF reader.
As @mb21 suggested, you can build from the command line. I sometimes use BAT/CMD files to store lengthy, or complicated build commands (since I'm on Windows). For example, in my document source directory, I might have make.cmd
, which contains:
pandoc --filter=pandoc-crossref --filter=pandoc-citeproc --smart --listings --number-sections --standalone file.md -o file.pdf
Then I run make.cmd
from the command prompt using `./make.cmd'.
Alternatively, you could use Makefile.
Install atom-script
. Then, configure your run options (Ctrl-Alt-Shift-O, on Windows) with something along the lines of the following:
Command: pandoc
Command Arguments: --filter=pandoc-crossref --filter=pandoc-citeproc --standalone file.md -o file.pdf
As you edit your source and would like to update the PDF, you can execute the command via Ctrl-Shift-B
panzer
You'll still need Atom's script
package, but you'll also need to get panzer
which is a utility that helps manage build configurations for pandoc.
Edit:
Rather than having to press a key combination (e.g. building from command line or using atom-script
), I thought of automatically building the output PDF upon saving using Grunt. I've captured the basic idea in this gist