JSPM

ascii-math

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

ascii-math to MathML conversion on the server side

Package Exports

  • ascii-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 (ascii-math) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ascii-math

This is an implimentation of asciimath. It lets you write plain text maths and have it be nicely formatted for you before display. Since it's a server side sollution it offers a much nicer user experience than MathJax or the original asciimath did. You can also use this function on the client if you prefer.

Installation

$ npm install ascii-math

Server side usage

On the server you can generate text that can be placed inline straight into an html document.

var parse = require('ascii-math');

var res = parse('e^(i pi)=-1').toString();
// => "<math title="e^(i pi)=-1"><msup><mi>e</mi><mrow><mi>i</mi><mi>&pi;</mi></mrow></msup><mo>=</mo><mo>-</mo><mn>1</mn></math>"

Client side usage

On the client it is recommended that you use .toElement() but .toString() still works. You should use it via browserify.

var parse = require('ascii-math');

var resA = parse('e^(i pi)=-1').toString();
// => "<math title="e^(i pi)=-1"><msup><mi>e</mi><mrow><mi>i</mi><mi>&pi;</mi></mrow></msup><mo>=</mo><mo>-</mo><mn>1</mn></math>"
div.innerHTML = resA;

var resB = parse('e^(i pi)=-1').toElement();//this method fails on the server
// => <math title="e^(i pi)=-1"><msup><mi>e</mi><mrow><mi>i</mi><mi>&pi;</mi></mrow></msup><mo>=</mo><mo>-</mo><mn>1</mn></math>
div.appendChild(resB);