Github Markdown To Pdf
Article version: GitHub.com
Article version: GitHub.com
Generate HTML & PDF documentation from Github wiki or any other markdown-based wiki. Conversion of a Markdown to a PDF file using Pandoc # pandoc -s -S README.md -o /tmp/README.pdf However, when you have very long lines (code, logs, etc), the lines are not automatically wrapped (so you loose information). To automatically wrap long lines using nice arrows, edit the pandoc PDF template (default.latex by default).
Share samples of code with fenced code blocks and enabling syntax highlighting.
In this article
Fenced code blocks
You can create fenced code blocks by placing triple backticks ```
before and after the code block. We recommend placing a blank line before and after code blocks to make the raw formatting easier to read.
Tip: To preserve your formatting within a list, make sure to indent non-fenced code blocks by eight spaces.
Syntax highlighting
You can add an optional language identifier to enable syntax highlighting in your fenced code block.
For example, to syntax highlight Ruby code:
We use Linguist to perform language detection and to select third-party grammars for syntax highlighting. You can find out which keywords are valid in the languages YAML file.
Further reading
- 'Basic writing and formatting syntax'
This post reviews several methods for converting a Markdown (.md) formatted file to PDF, from UNIX or Linux machines.
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. Timer for mac os.
grip will render the markdown on localhost:5000 - just edit away and refresh the browser. Print when ready.
Github Markdown To Pdf Pandoc
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
Github Print Markdown To Pdf
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.