Skip to content

Markdown-it plugin for creating block-level containers and with metadata.

License

Notifications You must be signed in to change notification settings

coinspect/markdown-it-data-blocks

Repository files navigation

markdown-it-data-blocks

Markdown-it plugin for creating block-level containers with metadata.

Description

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.

Example

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"
}

Installation

npm install markdown-it-data-blocks --save

Usage

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 })

Options

Show options:

import {parseOptions} from 'markdown-it-data-blocks'

const options = parseOptions({})
console.log(options)

About

Markdown-it plugin for creating block-level containers and with metadata.

Resources

License

Stars

Watchers

Forks

Packages

No packages published