Batch convert Markdown files into HTML.
Install node.js 0.6.0+ and run:
sudo npm install gh-markdown-cli -g
This will create an alias to the executable on your
if you install it without the
-g flag you won't be able use it as global
mdown --input "**/*.md" --output doc
This will convert any
.md files it can find inside the
and it's child folders and output them into the
If you want to convert only files inside the directory itself but ignore child
folders change the
--input glob to
mdown -i "src/*.md" -o doc
And to convert just a single file and output it into the current folder:
mdown -i "foo.md" -o .
You can specify HTML files to be used as header and footer of all the pages:
mdown -i "*.md" -o dist --header "assets/header.html" --footer "assets/header.html"
It also works with
stdout, so you can pipe other command-line
cat foo.md | mdown > foo.html echo "# foo" | mdown curl https://raw.github.com/millermedeiros/gh-markdown-cli/master/README.md | mdown
If you don't specify the
--output it will echo the result to
stdout by default.
Since this tool works with the
stdout you can use it from inside Vim to
convert the selected text into HTML:
vnoremap <silent> <leader>md :! mdown<CR>
Or if you want to convert the whole file content:
Plugins for other text editors can probably be easily coded.
For a list of all available options run
$ mdown -h Usage: mdown [options] Options: -h, --help output usage information -V, --version output the version number -o, --output <name> Output directory or output file name if using stdin for input. -i, --input <glob> Glob used for inclusion. Eg: "**/*.md" will convert all the ".md" files inside current folder and all its child folders. --exclude <globs> Comma separated list of globs used for exclusion. Defaults to "node_modules/**" --header <path> Path to HTML file used as header on all documents. --footer <path> Path to HTML file used as footer on all documents. --encoding <encoding> File encoding. Defaults to "utf-8".
The real work was done by the creators of the open source libraries used by this project (node-glob, minimatch, wrench-js, github-flavored-markdown, commander.js), I only assembled things together to make it easier to use, the credit should go to them.