Package Exports
- @acyort/markdown
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@acyort/markdown) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Markdown
Markdown parser with code highlight
Install
$ npm i @acyort/markdown -SUsage
const Marked = require('@acyort/markdown')
const config = {
lineNumbers: true, // show code line numbers
simpleMode: false, // simple markdown parser, not highlights code, not heading id
headingIdFormater: fn // heading id format function
}
const marker = new Marked(config)
// parse option, this override initialization optons
const option = {
lineNumbers: true,
simpleMode: false,
headingIdFormater: fn
}
// parse markdown string
marker.parse('# H1')
// width option
marker.parse('# H1', option)
marker.parse('# An h1 header')
// <h1>
// <a href="#An h1 header" id="An h1 header" class="heading"></a>
// An h1 header
// </h1>
const option = { headingIdFormater: () => 'heading' }
marker.parse('# An h1 header', options)
// <h1>
// <a href="#heading" id="heading" class="heading"></a>
// An h1 header
// </h1>
const code = '\`\`\`html\n<h1>h1</h1>\n\`\`\`'
marker.parse(code)
// <div class="hljs html">
// <table>
// <tbody>
// <tr>
// <td class="line">
// <pre>
// <span>1</span>
// </pre>
// </td>
// <td class="code">
// <pre>
// <span class="hljs-tag"><<span class="hljs-name">h1</span>></span>h1<span class="hljs-tag"></<span class="hljs-name">h1</span>></span>
// </pre>
// </td>
// </tr>
// </tbody>
// </table>
// </div>
marker.parse(code, { simpleMode: true })
// <pre>
// <code><h1>h1</h1></code>
// </pre>
// more examples in test folder