mdast extension for definition list
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)
From npm:
$ npm install mdast-util-definition-list
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);