JSPM

@acyort/markdown

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 51
  • Score
    100M100P100Q41304F
  • License MIT

Markdown parser with code highlight

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

Build Status codecov

Markdown parser with code highlight

Install

$ npm i @acyort/markdown -S

Usage

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">&lt;<span class="hljs-name">h1</span>&gt;</span>h1<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
//           </pre>
//         </td>
//       </tr>
//     </tbody>
//   </table>
// </div>

marker.parse(code, { simpleMode: true })
// <pre>
//   <code>&lt;h1&gt;h1&lt;&#x2F;h1&gt;</code>
// </pre>

// more examples in test folder