markdown-it-front-matter

2019-10-10 admin

markdown-it-front-matter是什么

什么是markdown-it-front-matter,Plugin to process front matter container for markdown-it markdown parser

markdown-it-front-matter使用教程帮助文档

markdown-it-front-matter

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

npm

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

Code heavily borrowed from markdown-it-container

Thank you:

puzrin

rlidwka

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-77045.html

文章标题:markdown-it-front-matter

回到顶部