Skip to content

wataru-chocola/mdast-util-definition-list

Repository files navigation

mdast-util-definition-list

Node.js CI

mdast extension for definition list

Feature

This package provides mdast utilities to handle definition list with micromark-extension-definition-list.

This includes:

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

About

mdast extension for definition list

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •