This post reviews several methods for converting a Markdown (.md) formatted file to PDF, from UNIX or Linux machines.
It was developed in 2004 by John Gruber, who wrote the first markdown-to. The official reference implementation and validation test suite on GitHub. It is common for Markdown to include HTML. HTML is treated as a 'code block'. There is no attempt to convert raw HTML to PDF. Github-flavored Markdown permits strikethough using tildes. This is not supported at present by gofpdf as a font style. The markdown link title, which would show when converted to HTML as hover-over text, is not supported.
Using Pandoc
:
Other methods:
GRIP
http://superuser.com/questions/689056/how-can-i-convert-github-flavored-markdown-to-a-pdfI've had success using grip to display markdown in Chrome and then use Chrome's 'Save as PDF' option in the Print dialog.
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).
Node.js
http://superuser.com/questions/689056/how-can-i-convert-github-flavored-markdown-to-a-pdfYou can also use Node.js based markdown-pdf
NOTES:
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 toread than GRIP output PDF.
We use GitHub Wikis for planning and documentation. This makes sense for usbecause we use GitHub to manage almost all of our projects. Another majorreason is that we prefer to use text files over binaries. Since GitHub Wikissupport Markdown, we can easily create tables and checklists in our Wikis. Ofcourse, that also means we can use Vim, Git and many of the other command linetools that we love.
Some organizations have turned wiki maintenance into an art form. GitHub has ashowcase just on this subject. From the list, Netflix and Guard are probably the best.
For any repository hosted on GitHub, its wiki can be cloned by appending.wiki
at the end of the git URL. So, for our energyviz
repository, itwould be:
We like to organize our wikis, so we usually add _Sidebar.md
to it. This allows us to override the default sidebar by manually re-arranging the content of the wiki. Here is a sample _Sidebar.md
:
Vundle and Vim-Markdown
Since we use Vim, it helps to have syntax highlighting for Markdown. We can use Vundle to install Vim-Markdown plugin:
- Install Vundle
- Add the following at the top of your .vimrc:
- After saving and existing .vimrc, run the following command:
Vim should now properly identify our Markdown files.
Preview Locally
Since we were already used to working with Jekyll, we wondered if there was aneasy way for us to preivew our wiki pages locally before pushing them toGitHub. There are a couple of tools that can do this, and we found gfms to bethe best one for us. gfms stands for Github Flavored Markdown Server (GFMS).
gfms is powered by NodeJS, so we can use npm to install it:
We can then cd into our wiki dir and fire it up:
One of the things we love about gfms is that it automatically refreshes the browser window when the file is saved.
You will notice that it writes out remaining API requests each time you save a file.
That is the number of requests you have remaining for unauthenticated requests.That is currently set at 60. You can check your limit with this command:
Github Markdown Pdf Image
Happy documentation!