Markdown-it plugin for creating block-level containers with metadata.
This plugin combines the features of: markdown-it-container and markdown-it-metadata-block
It allows to insert metadata in blocks and wrap that blocks in a class.
markdown:
--- my-block
title: Test block
foo: foo
bar: bar
This is a test block
/--
render:
<div class="my-block">
<h3>Test block</h3>
<p>This is a test block</p>
</div>
metadata:
{
"type": "my-block",
"title": "Test block",
"foo": "foo",
"bar": "bar"
}
npm install markdown-it-data-blocks --save
npm install markdown-it --save
npm install markdown-it-data-blocks --save
npm install yaml --save
import * as MarkdownIt from 'markdown-it'
import yaml from 'yaml'
import data_blocks from 'markdown-it-data-blocks'
const metadataParser = (str,data) => yaml.parse(str)
const markdown = new MarkdownIt().use(data_blocks, { metadataParser })
Show options:
import {parseOptions} from 'markdown-it-data-blocks'
const options = parseOptions({})
console.log(options)