Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including markdown-it-front-matter with all npm packages installed. Try it out:

var markdownItFrontMatter = require("markdown-it-front-matter")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

markdown-it-front-matter v0.2.1

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.

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

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free