Convert a package README to HTML.
var convert = require( '@stdlib/_tools/readme/to-html' );
Converts a package Markdown README file to HTML.
var file = '/foo/bar/README.md';
convert( file, clbk );
function clbk( error, html ) {
if ( error ) {
throw error;
}
console.log( html );
}
The function accepts the following options
:
- out: output file path.
- fragment:
boolean
indicating whether to output an HTML fragment. Iftrue
, all other options besideout
are ignored. Default:false
. - tests: tests URL.
- benchmarks: benchmarks URL.
- source: source URL.
- title: HTML title.
- head: content to insert into HTML head.
- prepend: content to prepend to HTML body (after navigation).
- append: content to append to HTML body.
To specify an output file path, set the out
option.
var file = '/foo/bar/README.md';
var opts = {
'out': '/foo/bar/test.html'
};
convert( file, opts, clbk );
function clbk( error ) {
if ( error ) {
throw error;
}
}
To generate only an HTML fragment (i.e., equivalent of directly converting a Markdown file to HTML), set the fragment
option to true
.
var file = '/foo/bar/README.md';
var opts = {
'fragment': true
};
convert( file, opts, clbk );
function clbk( error, html ) {
if ( error ) {
throw error;
}
console.log( html );
}
To understand how other options
affect HTML output, see the HTML template in ./static
.
var resolve = require( 'path' ).resolve;
var convert = require( '@stdlib/_tools/readme/to-html' );
var fpath = resolve( __dirname, '..', 'README.md' );
var opts = {
'title': 'Beep',
'source': 'https://github.com/stdlib-js/stdlib/develop/tools/readme/to-html/lib/index.js',
'append': '<script type="text/javascript">console.log("Beep!");</script>'
};
convert( fpath, opts, onFinish );
function onFinish( error, html ) {
if ( error ) {
throw error;
}
console.log( html );
}
Usage: readme-to-html [options] <file>
Options:
-h, --help Print this message.
-V, --version Print the package version.
--fragment Output an HTML fragment.
--tests url Tests URL.
--benchmarks url Benchmarks URL.
--source url Source URL.
--title title HTML title.
--head html Content to insert into HTML head.
--prepend html Content to prepend to HTML body.
--append html Content to append to HTML body.
- If provided the
--fragment
command-line option, all other command-line options affecting HTML output are ignored.
$ readme-to-html ./README.md