mdast-util-definition-list
v2.0.0
Published
mdast extension for definition list
Downloads
4,512
Maintainers
Readme
mdast-util-definition-list
mdast extension for definition list
Feature
This package provides mdast utilities to handle definition list with micromark-extension-definition-list.
This includes:
defListFromMarkdown
: mdast-util-from-markdown extension (markdown -> mdast)defListToMarkdown
: mdast-util-to-markdown extension (mdast -> markdown)defListHastHandlers
: mdast-util-to-hast extension (mdast -> hast)
Install
From npm:
$ npm install mdast-util-definition-list
Use
import {
defListFromMarkdown,
defListToMarkdown,
defListHastHandlers,
} from 'mdast-util-definition-list';
import { defList } from 'micromark-extension-definition-list';
import { fromMarkdown } from 'mdast-util-from-markdown';
import { toMarkdown } from 'mdast-util-to-markdown';
import { toHast } from 'mdast-util-to-hast';
const md = `
Apple
: Pomaceous fruit of plants of the genus Malus in
the family Rosaceae.
Orange
: The fruit of an evergreen tree of the genus Citrus.
`;
const mdast = fromMarkdown(md, {
extensions: [defList],
mdastExtensions: [defListFromMarkdown],
});
console.log(mdast);
const markdown = toMarkdown(mdast, {
extensions: [defListToMarkdown],
});
console.log(markdown);
const hast = toHast(mdast, {
handlers: defListHastHandlers,
});
console.log(hast);