toVirtualDOM

Convert Markdown to Virtual DOM.

Usage

var toVirtualDOM = require( '@stdlib/_tools/markdown/to-vdom' );

toVirtualDOM( markdown )

Converts a Markdown string or Buffer to a Virtual DOM tree.

var vtree = toVirtualDOM( '# Beep\n\n> Boop!' );
// returns <VTree>

Examples

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

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

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

var vtree = toVirtualDOM( file );
console.log( toHTML( vtree ) );

CLI

Usage

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

Options:

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

Examples

$ markdown-to-vdom '# Beep\n\n> Boop!'

To use as a standard stream,

$ echo $'# Beep\n\n> Boop!' | markdown-to-vdom