Convert Markdown to HTML.
var toHTML = require( '@stdlib/_tools/markdown/to-html' );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>'
}By default, the plugin resolves package identifiers to /docs/api/develop/ documentation paths. To specify an alternative base path, set the base option.
toHTML( '[@stdlib/boop](https://github.com/stdlib-js/stdlib)', '/docs/api/v0.0.90/', done );
function done( error, html ) {
if ( error ) {
throw error;
}
console.log( html );
// => '<a href="https://github.com/docs/api/v0.0.90/@stdlib/boop">@stdlib/boop</a>'
}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 );
}Usage: markdown-to-html [options] [<markdown>]
Options:
-h, --help Print this message.
-V, --version Print the package version.
--base Base path for internal URLs.$ 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>