Markdown.compileToHtml()

Compile a Markdown string into an HTML string.

Expects GitHub-flavored Markdown syntax. Uses [`marked`](https://github.com/chjj/marked).

Usage

Hover over inputs/exits for more info.

var Markdown = require('machinepack-markdown');


// Compile a Markdown string into an HTML string.

Markdown.compileToHtml({

mdString: '# hello world\n it\'s me, some markdown string \n\n ```js\n//but maybe i have code snippets too...\n```',

escapeHtml: false,

compileCodeBlock: '->',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

mdString required

Markdown string to convert

'# hello world\n it\'s me, some markdown string \n\n ```js\n//but maybe i have code snippets too...\n```'
escapeHtml

If enabled, any inline HTML in the source Markdown will be escaped instead of injected literally in the HTML output.

false
compileCodeBlock

An optional lifecycle callback useful for adding syntax highlighting to code blocks, or to perform custom HTML-escaping on them.

'->'

Exits

error

An unexpected error occurred.

success

OK.

'<h1 id="hello-world">hello world</h1>\n<p> it's me, some markdown string </p>\n<pre><code class="lang-js">//but maybe i have code snippets too...</code></pre>\n'