This post reviews several methods for converting a Markdown (.md) formatted file to PDF, from UNIX or Linux machines.
$ pandoc How_I_got_svg-resizer_working_on_Mac_OSX.md -s -o test1.pdf
http://superuser.com/questions/689056/how-can-i-convert-github-flavored-markdown-to-a-pdf I've had success using grip to display markdown in Chrome and then use Chrome's "Save as PDF" option in the Print dialog.
pip install grip
grip your_markdown.md
grip
will render the markdown on localhost:5000 ... - just edit away and refresh the browser. Print when ready.
This gave a more reliable representation than pandoc
and was lighter weight than installing LaTeX (required by pandoc for pdf generation).
The print is not command line in this answer, but still found this easier/more reliable (looked 100% like Github for a long document including relatively linked images and code highlighting).
http://superuser.com/questions/689056/how-can-i-convert-github-flavored-markdown-to-a-pdf You can also use Node.js based markdown-pdf
npm install -g markdown-pdf
markdown-pdf /path/to/markdown
The GRIP results look just like GitHub README pages. The Pandoc result looks like (is) LaTex format. And the Node.js result is the most original looking, but slightly harder to read than GRIP output PDF. Overall, I prefer GRIP output.
You can also use gh-md-to-html for this, which is a command line tool that can also convert markdown to pdf (despite its name).
You can install it by installing
wkhtmltopdf
and then installinggh-md-to-html
withAnd then use
The
-p
option declares under which file name to save the resulting pdf file; the "<name>
" is automatically replaced with the name of your input file.Under to hood,
gh-md-to-html
converts the file to html (as the name suggests) and then from html to pdf usingwkhtmltopdf
.The resulting pdf file is, in any case, styled similar to how GitHub styles their README files; if you want to disable that, you can supply the option
-s false
to the command, which disables the default styling.Code blocks are properly syntax highlighted in both cases, though.
The conversion process is done partially online (using GitHub's markdown REST API); in case you don't want that, you can use
pip3 install gh-md-to-html[offline_conversion]
and then rungh-md-to-html
with the-o OFFLINE
option.gh-md-to-html
also supports inline-formulas like pandoc (but has some advantages over it when it comes to markdown-flavor-tolerance rather than looks, as describes in its README), and supports the[[_TOC_]]
syntax of GitLab-flavored markdown (both features can be disabled). It also supports supplying custom CSS to style the output.