remark-definition-list
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

remark-definition-list

Node.js CI

remark plugin to support definition list

Feature

Install

$ npm install remark-definition-list

Use

Markdown -> HTML

import { remarkDefinitionList, defListHastHandlers } from 'remark-definition-list';
import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
import rehypeStringify from 'rehype-stringify';

const md = `
Test for defList.

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 html = await unified()
  .use(remarkParse)
  .use(remarkDefinitionList)
  .use(remarkRehype, {
    handlers: {
      // any other handlers
      ...defListHastHandlers,
    }
  })
  .use(rehypeStringify)
  .process(md);

HTML -> Markdown

import { remarkDefinitionList, defListHastToMdast } from 'remark-definition-list';
import { unified } from 'unified';

import rehypeParse from 'rehype-parse';
import rehypeRemark from 'rehype-remark';
import remarkStringify from 'remark-stringify';

const html = `
<p>Test for defList.</p>
<dl>
<dt>Apple</dt>
<dd>Pomaceous fruit of plants of the genus Malus in
the family Rosaceae.
</dd>
<dt>Orange</dt>
<dd>The fruit of an evergreen tree of the genus Citrus.
</dd>
</dl>`;

const html2md = await unified()
  .use(rehypeParse, { fragment: true })
  .use(rehypeRemark, {
    handlers: defListHastToMdast,
  })
  .use(remarkDefinitionList)
  .use(remarkStringify)
  .process(html);

Package Sidebar

Install

npm i remark-definition-list

Weekly Downloads

501

Version

2.0.0

License

MIT

Unpacked Size

6.41 kB

Total Files

5

Last publish

Collaborators

  • wataru-chocola