remark-inline-math
This is a remark plugin to support inline math surrounded by dollar signs.
⚠️ It's highly recommended to use
remark-math
instead of this package.
Usage
const unified = require('unified');
const parse = require('remark-parse');
const remarkInlineMath = require('@bizen241/remark-inline-math');
const doc = '$1\\$ = 1$';
const ast = unified()
.use(parse)
.use(remarkInlineMath)
.parse(doc);
Yields:
{
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "inlineCode",
"value": "1\\$ = 1",
"data": {
"lang": "math"
}
}
]
}
]
}
or
<p><code>1\$ = 1</code></p>
API
origin.use(remarkInlineMath[, options])
options
builder
(Function
)@param {string} value
- math expression (e.g.1 + 1 = 2
)@returns {MdastNode}
- MDAST node
Example:
const options = {
builder: (value) => ({
type: 'inlineCode',
value,
data: {
hName: 'math',
},
}),
};
License
MIT © bizen241