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 found a website that will do this for you: http://tmpvar.com/markdown.html. Paste in your Markdown, and it'll display it for you. It seems to work just fine!
However, it doesn't seem to handle the syntax highlighting option for code; that is, the
~~~ruby
feature doesn't work. It just prints 'ruby'.I managed to use a one-line Ruby script for that purpose (although it had to go in a separate file). First, run these commands once on each client machine you'll be pushing docs from:
Next, install this script in your client image, and call it
render-readme-for-javadoc.rb
:Finally, invoke it like this:
ETA: This won't help you with StackOverflow-flavor Markdown, which seems to be failing on this answer.
A 'quick-and-dirty' approach is to download the wiki HTML pages using the
wget
utility, instead of cloning it. For example, this is how I downloaded the Hystrix wiki from GitHub (I'm using Ubuntu Linux):The first call will download the wiki entry page and all its dependencies. The second one will call all sub-pages on it. You can browse now the wiki by opening
Netflix/Hystrix/wiki.1.html
.Note that both calls to
wget
are necessary. If you just run the second one then you will miss some dependencies required to show the pages properly.Improving upon @barry-stae and @Sandeep answers for regular users of elinks you would add the following to .bashrc:
Don't forget to install pandoc (and elinks).
There is a really nice and simple tool for browsing GFM Markdown documents:
GFMS - Github Flavored Markdown Server
It's simple and lightweight (no configuration needed) HTTP server you can start in any directory containing markdown files to browse them.
Features:
Probably not what you want, but since you mentioned Node.js: I could not find a good tool to preview GitHub Flavored Markdown documentation on my local drive before committing them to GitHub, so today I created one, based on Node.js: https://github.com/ypocat/gfms
So perhaps you can reuse the showdown.js from it for your Wiki, if your question is still actual. If not, maybe other people facing the same problem as I did will find (just as I did) this question and this answer to it.