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
Also see https://softwareengineering.stackexchange.com/a/128721/24257.
If you're interested in how we [Github] render Markdown files, you might want to check out Redcarpet, our Ruby interface to the Sundown library.
Ruby-script, which use Redcarpet, will be "command line utility", if you'll have local Ruby
Improving upon @barry-stae and @Sandeep answers for regular users of elinks you would add the following to .bashrc:
function mdviewer() {
pandoc $* | elinks --force-html
}
Don't forget to install pandoc (and elinks).
GitHub has a Markdown API you can use.
Use marked. It supports GitHub Flavored Markdown, can be used as a Node.js module and from the command line.
An example would be:
$ marked -o hello.html
hello world
^D
$ cat hello.html
<p>hello world</p>
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:
gem install github-markup
gem install commonmarker
Next, install this script in your client image, and call it render-readme-for-javadoc.rb
:
require 'github/markup'
puts GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, File.read('README.md'))
Finally, invoke it like this:
ruby ./render-readme-for-javadoc.rb >> project/src/main/javadoc/overview.html
ETA: This won't help you with StackOverflow-flavor Markdown, which seems to be failing on this answer.
I've not found a quick and easy method for GitHub-flavoured Markdown, but I have found a slightly more generic version - Pandoc. It converts from/to a number of formats, including Markdown, Rest, HTML and others.
I've also developed a Makefile
to convert all .md files to .html (in large part to the example at Writing, Markdown and Pandoc):
# 'Makefile'
MARKDOWN = pandoc --from gfm --to html --standalone
all: $(patsubst %.md,%.html,$(wildcard *.md)) Makefile
clean:
rm -f $(patsubst %.md,%.html,$(wildcard *.md))
rm -f *.bak *~
%.html: %.md
$(MARKDOWN) $< --output $@