2.0.0 • Published 7 months ago

micromark-extension-definition-list v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

micromark-extension-definition-list

Node.js CI

micromark extension to support definition lists.

Compatibility Note

This extension might not work with other extensions.

The plugin's tokenizer needs knowledge about token types that other tokenizers generate to create defList. If you find any extensions not working with this, please create issue.

Feature

Install

Install from npm.

$ npm install micromark-extension-definition-list

Use

import { micromark } from 'micromark';
import { defList, defListHtml } from 'micromark-extension-definition-list';

const markdown = `
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 output = micromark(markdown, {
  extensions: [defList],
  htmlExtensions: [defListHtml]
});

Known Issues

dd-like line stops parsing gfm-table

Input:

head
| - |
row1
: row2

Expected HTML:

<table>
  <thead>
    <tr><th>head</th></tr>
  </thead>
  <tbody>
    <tr><td>row1</td></tr>
    <tr><td>: row2</td></tr>
  </tbody>
</table>

Actual behavior:

<table>
  <thead>
    <tr><th>head</th></tr>
  </thead>
  <tbody>
    <tr><td>row1</td></tr>
  </tbody>
</table>
<p>: row2</p>

Workaround: Escape colon at the start of line

head
| - |
row1
\: row2

Test in development

For development purpose, you can run tests with debug messages.

$ DEBUG="micromark-extension-definition-list:*" npm run test-dev -- -t <title_pattern>