gh-markdown-cli

0.2.0 • Public • Published

Github Flavored Markdown Node.js CLI

Batch convert Markdown files into HTML.

Installation

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 /usr/local/bin folder, if you install it without the -g flag you won't be able use it as global command-line utility.

Usage example

Basic

mdown --input "**/*.md" --output doc

This will convert any .md files it can find inside the --input directory and it's child folders and output them into the --output folder.

If you want to convert only files inside the directory itself but ignore child folders change the --input glob to "*.md":

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 .

Header / Footer

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"

stdin / stdout

It also works with stdin and stdout, so you can pipe other command-line tools like echo, cat, curl, etc...

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.

More

For a list of all available options run mdown -h:

$ 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".

Important

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.

License

WTFPL

Readme

Keywords

none

Package Sidebar

Install

npm i gh-markdown-cli

Weekly Downloads

50

Version

0.2.0

License

none

Last publish

Collaborators

  • millermedeiros