markdown-it-front-matter

Plugin to process front matter container for markdown-it markdown parser

markdown-it-front-matter

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

Valid Front Matter

Essentially, valid front matter is a fenced block:

  • Indicated by threeor moredashes: ---
  • Opening and closing fences must be the same number of dashcharacters
  • 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 requiredcallback 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

Code heavily borrowed from markdown-it-container

Thank you:

puzrin

rlidwka

Repository

https://github.com/craigdmckenna/markdown-it-front-matter


上一篇:markdown-it-jsx
下一篇:markdown-it-external-links

相关推荐

官方社区

扫码加入 JavaScript 社区