toHTML

Convert Markdown to HTML.

Usage

var toHTML = require( '@stdlib/_tools/markdown/to-html' );

toHTML( markdown, done )

Converts a Markdown string or Buffer to HTML.

toHtml( '# Beep\n\n> Boop!', done );

function done( error, html ) {
    if ( error ) {
        throw error;
    }
    console.log( html );
    // => '<h1 id="beep">Beep</h1>\n\n<blockquote>\n<p>Boop!</p>\n</blockquote>'
}

Examples

var join = require( 'path' ).join;
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
var toHTML = require( '@stdlib/_tools/markdown/to-html' );

var file = join( __dirname, 'examples', 'fixtures', 'fixture.md' );

file = readFileSync( file, {
    'encoding': 'utf8'
});
if ( file instanceof Error ) {
    throw file;
}

toHTML( file, done );

function done( error, html ) {
    if ( error ) {
        throw error;
    }
    console.log( html );
}

CLI

Usage

Usage: markdown-to-html [options] [<markdown>]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.

Examples

$ markdown-to-html '# Beep\n\n> Boop!'
<h1 id="beep">Beep</h1>
<blockquote>
<p>Boop!</p>
</blockquote>

To use as a standard stream,

$ echo $'# Beep\n\n> Boop!' | markdown-to-html
<h1 id="beep">Beep</h1>
<blockquote>
<p>Boop!</p>
</blockquote>