@paperist/remark-math
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.0 • Public • Published

    @paperist/remark-math

    LICENSE NPM standard-readme compliant

    wooorm/remark plugin for math likes KaTeX / MathJax

    Table of Contents

    Install

    npm i remark @paperist/remark-math
    

    Usage

    const unified = require('unified');
    const parser = require('remark-parse');
    const math = require('@paperist/remark-math');
     
    const markdown = `
    In an x-y Cartesian coordinate system,
    the circle with centre coordinates \\((a, b)\\) and
    radius \\(r\\) is the set of all points \\((x, y)\\) such that
     
    \\[
    (x - a)^2 + (y - b)^2 = r^2
    \\]
     
    https://en.wikipedia.org/wiki/Circle
    `;
     
    const processor = unified()
      .use(parser)
      .use(math);
    const ast = processor.parse(markdown);
     
    processor.run(ast).then((ast) => {
      console.dir(ast, { depth: null });
    });

    AST

    See also mdast, unist.

    Math

    Math extends Literal.

    interface Math extends Literal {
      type: 'math';
      math: string;
    }

    For example, the following markdown:

    \[
    x^2 + y^2 = r^2
    \]

    Yields:

    {
      "type": "math",
      "value": "\\[\nx^2 + y^2 = r^2\n\\]",
      "math": "\nx^2 + y^2 = r^2\n"
    }

    InlineMath

    InlineMath extends Literal.

    interface InlineMath extends Literal {
      type: 'inlineMath';
      math: string;
    }

    For example, the following markdown:

    \(E = mc^2\)

    Yields:

    {
      "type": "inlineMath",
      "value": "\\(E = mc^2\\)",
      "math": "E = mc^2"
    }

    Contribute

    PRs accepted.

    License

    MIT (c) 3846masa

    Install

    npm i @paperist/remark-math

    DownloadsWeekly Downloads

    8

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    45.6 kB

    Total Files

    15

    Last publish

    Collaborators

    • 3846masa
    • paperist-owner