JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1451
  • Score
    100M100P100Q98774F
  • License MIT

Markdown-it plugin to include math in your document

Package Exports

  • markdown-it-math

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (markdown-it-math) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

markdown-it-math

Pythagoran theorem is $$a^2 + b^2 = c^2$$.

Bayes theorem:

$$$
P(A | B) = (P(B | A)P(A)) / P(B)
$$$
<p>Pythagoran theorem is <math><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>=</mo><msup><mi>c</mi><mn>2</mn></msup></math>.</p>
<p>Bayes theorem:</p>
<math display="block">
<mi>P</mi><mfenced open="(" close=")"><mrow><mi>A</mi><mo stretchy="true" lspace="veryverythickmathspace" rspace="veryverythickmathspace">|</mo><mi>B</mi></mrow></mfenced><mo>=</mo><mfrac><mrow><mi>P</mi><mfenced open="(" close=")"><mrow><mi>B</mi><mo stretchy="true" lspace="veryverythickmathspace" rspace="veryverythickmathspace">|</mo><mi>A</mi></mrow></mfenced><mi>P</mi><mfenced open="(" close=")"><mi>A</mi></mfenced></mrow><mrow><mi>P</mi><mfenced open="(" close=")"><mi>B</mi></mfenced></mrow></mfrac></math>

Installation

npm install markdown-it-math --save

Usage

var md = require('markdown-it')()
        .use(require('markdown-it-math') [, options | renderer]);

If renderer function is not provided, it will default to require('ascii2mathml')(options) (see here for info).

Examples

Using comma as a decimal mark

var md = require('markdown-it')()
        .use(require('markdown-it-math'), {decimalMark: ','});

md.render("$$40,2$$");
// <p><math><mn>40,2</mn></math></p>

Using TeXZilla as renderer

var texzilla = require('texzilla');
var md = require('markdown-it')()
        .use(require('markdown-it-math'), function(str) {
            // We need to strip the root math element out
            return texzilla.toMathMLString(str).slice(49, -7);
        });

md.render("$$\\sin(2\\pi)$$");
// <semantics><mrow><mo lspace="0em" rspace="0em">sin</mo><mo stretchy="false">(</mo><mn>2</mn><mi>π;</mi><mo stretchy="false">)</mo></mrow><annotation encoding="TeX">\sin(2\pi)</annotation></semantics>