markdown-it-front-matter
TypeScript icon, indicating that this package has built-in type declarations

0.2.4 • Public • Published

markdown-it-front-matter

npm master-ci

Plugin for processing front matter for markdown-it markdown parser.

Install

$ npm install markdown-it-front-matter --save

Valid Front Matter

Essentially, valid front matter is a fenced block:

  • Indicated by three or more dashes: ---
  • Opening and closing fences must be the same number of dash characters
  • Opening fence must begin on the first line of the markdown string/file
  • Opening fence must not be indented
---
valid-front-matter: true
---

The example above uses YAML but YAML is not required

(bring your own front matter parser)

Example

  • Front Matter is not rendered.
  • Any markup inside the block is passed to the required callback function.
const md = require('markdown-it')()
  .use(require('markdown-it-front-matter'), function(fm) {
    console.log(fm)
  });

let result = md.render('---\ntitle: This is the Title\n---\n# Heading\n----\nsome text');

// > title: This is the Title

References / Thanks

Code heavily borrowed from markdown-it-container

License

markdown-it-front-matter is distributed under the MIT License - see the LICENSE file for details.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.4
    2,962
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.4
    2,962
  • 0.2.3
    2,377
  • 0.2.2
    0
  • 0.2.1
    3,072
  • 0.1.2
    25
  • 0.1.1
    0

Package Sidebar

Install

npm i markdown-it-front-matter

Weekly Downloads

8,436

Version

0.2.4

License

MIT

Unpacked Size

10.9 kB

Total Files

7

Last publish

Collaborators

  • craigdmckenna
  • parksb