I'm wondering if there is a command line utility for taking a GitHub flavored Markdown file and rendering it to HTML.
I'm using a GitHub wiki to create website content. I've cloned the repository on my server and would then like to process it into regular HTML. It's important to me that what appears on GitHub is exactly how it should look for my website. I'd also really like to use the fenced blocks with ~~~
, so I'd rather not use standard Markdown syntax only.
I've looked a bit into the JavaScript live preview thinking I could hook it into Node.js, but they say it is deprecated. I've looked at the redcarpet repository, but it doesn't look like it has a command line interface.
I rolled my own solution, however, since no solution here is clearly better than the others, I'll leave the question without a selected answer.
I recently made what you want, because I was in need to generate documentation from Markdown files and the GitHub style is pretty nice. Try it. It is written in Node.js.
gfm
This is mostly a follow-on to @barry-staes's answer for using Pandoc. Homebrew has it as well, if you're on a Mac:
Pandoc supports GFM as an input format via the
markdown_github
name.Output to file
Open in Lynx
Open in the default browser on OS X
TextMate Integration
You can always pipe the current selection or current document to one of the above, as most editors allow you to do. You can also easily configure the environment so that
pandoc
replaces the default Markdown processor used by the Markdown bundle.First, create a shell script with the following contents (I'll call it
ghmarkdown
):You can then set the
TM_MARKDOWN
variable (in Preferences→Variables) to/path/to/ghmarkdown
, and it will replace the default Markdown processor.My final solution was to use Python Markdown. I rolled my own extension that fixed the fence blocks.
Late addition but showdownjs has a CLI tool you can use to parse MD to HTML.
Maybe this might help:
No documentation exists, but I got it from the gollum documentation. Looking at rubydoc.info, it looks like you can use:
in your Ruby code. You can wrap that easily in a script to turn it into a command line utility:
Execute it with
./render.rb path/to/my/markdown/file.md
. Note that this is not safe for use in production without sanitization.pandoc
withbrowser
works well for me.Usage:
cat README.md | pandoc -f markdown_github | browser
Installation (Assuming you are using Mac OSX):
$ brew install pandoc
$ brew install browser
Or on Debian/Ubuntu:
apt-get install pandoc browser