Built for docusaurus v2 s.t. it can be required (docusaurus is not yet ESM ready...).
Definition 1
: Explanation 1a
: Explanation 1b
Definition 2
: Explanation 2
AST (see mdast specification)
For example, the following markdown:
Definition 1
: Explanation 1a
Yields:
{
type: 'dl',
data: {
hName: 'dl'
},
children: [
{
type: 'dt',
data: {
hName: 'dt'
},
children: [{
type: 'text',
value: 'Definition 1'
}]
},
{
type: 'dd',
data: {
hName: 'dd'
},
children: [{
type: 'text',
value: 'Explanation 1a'
}]
}
]
}
This plugin is compatible with [rehype][https://github.com/rehypejs/rehype]. deflist
mdast nodes will become
<dl>
<dt>Definition</dt>
<dd>Explanation</dd>
<dd>...</dd>
</dl>
yarn add remark-deflist-simple
Dependencies:
const unified = require('unified')
const remarkParse = require('remark-parse')
const stringify = require('rehype-stringify')
const remark2rehype = require('remark-rehype')
const remarkDeflist = require('remark-deflist-simple')
Usage:
unified()
.use(remarkParse)
.use(remarkDeflist)
.use(remark2rehype)
.use(stringify)