@bizen241/remark-inline-math

Inline math support for remark

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@bizen241/remark-inline-math
600.3.07 years ago8 years agoMinified + gzip package size for @bizen241/remark-inline-math in KB

Readme

remark-inline-math
Build Status
This is a remark plugin to support inline math surrounded by dollar signs.

:warning: 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](https://github.com/syntax-tree/mdast)
Example:
const options = {
    builder: (value) => ({
        type: 'inlineCode',
        value,
        data: {
            hName: 'math',
        },
    }),
};

License

MIT © bizen241