Pandoc is a command-line tool built in Haskell that can convert almost any markup or word processing format interchangeably. You specify the input and the output types and pandoc will do the rest.
In this lesson we will convert a few markdown files to pdf. You will see how to convert a single file and then we'll write a script to loop through a couple files and convert them dynamically.
This lesson requires that you install pandoc
and have pdflatex
available.
You can install pandoc
with brew: brew install pandoc
To access pdflatex
, you can install basictex
and set the path for --pdf-engine
to pdflatex
Zac Jones: [0:00] I'm going to run ls. I see I have this markdown-file that I would like to convert to PDF. To do so, I'll run pandoc -f markdown -t pdf and input the file that I would like to convert, which is markdown file. I'll hit Run. You'll notice, instead of it running, it specifies we ran into an error and that I need to have a --pdf-engine set.
[0:33] I'll run that same command. This time I'll set the --pdf-engine flag to an engine I know I have installed on my system, which is pdflatex. This is because I have Basic TeX installed. You'll notice that pandoc outputted to standard out, which put this PDF file in the terminal. It's not too useful for us.
[0:55] I'm going to specify the output flag with -o and say from-markdown.pdf and hit Enter. We'll ls and see that this from-markdown was created. We can open it by saying open from-markdown.pdf. You'll see I successfully converted my markdown file to PDF.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!