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 con
I wrote a small CLI in Python and added GFM support. It's called Grip (Github Readme Instant Preview).
Install it with:
$ pip install grip
And to use it, simply:
$ grip
Then visit localhost:5000
to view the readme.md
file at that location.
You can also specify your own file:
$ grip CHANGES.md
And change port:
$ grip 8080
And of course, specifically render GitHub-Flavored Markdown, optionally with repository context:
$ grip --gfm --context=username/repo issue.md
Notable features:
stdin
and export to stdout
added in 3.0Hope this helps someone here. Check it out.
Improving upon @barry-stae's solution. Stick this snippet in ~/.bashrc
function mdviewer(){
pandoc $* | lynx -stdin
}
Then we can quickly view the file from the command-line. Also works nicely over SSH/Telnet sessions.
mdviewer README.md
pip3 install --user markdown
python3 -m markdown readme.md > readme.html
It doesn't handle GitHub extensions, but it is better than nothing. I believe you can extend the module to handle the GitHub additions.
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):
$ wget -e robots=off -nH -E -H -k -K -p https://github.com/Netflix/Hystrix/wiki
$ wget -e robots=off -nH -E -H -k -K -I "Netflix/Hystrix/wiki" -r -l 1 https://github.com/Netflix/Hystrix/wiki
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.
I created a tool similar to Atom's Preview functionality, but as a standalone application. Not sure if this is what you're looking for, but it might be helpful. -- https://github.com/yoshuawuyts/vmd
To read a README.md file in the terminal I use:
pandoc README.md | lynx -stdin
Pandoc outputs it in HTML format, which Lynx renders in your terminal.
It works great: It fills my terminal, shortcuts are shown below, I can scroll through, and the links work! There is only one font size though, but the colors + indentation + alignment make up for that.
Installation:
sudo apt-get install pandoc lynx