@bizen241/remark-inline-math

0.3.0 • Public • Published

remark-inline-math

Build Status

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

Readme

Keywords

Package Sidebar

Install

npm i @bizen241/remark-inline-math

Weekly Downloads

2

Version

0.3.0

License

MIT

Last publish

Collaborators

  • bizen241