GithubHelp home page GithubHelp logo

kedashoe / mathup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from runarberg/mathup

0.0 1.0 0.0 5.08 MB

Easy MathML authoring tool with a quick to write syntax

Home Page: https://runarberg.github.io/mathup

License: MIT License

JavaScript 100.00%

mathup's Introduction

mathup

npm License Build Status Coverage Status Downloads
npms Score

Installation

npm
npm install mathup
import mathup from "mathup";
Client

Download one of the released assets and include the module:

<script type="module" src="mathup.js"></script>

…the custom element:

<script type="module" src="math-up-element.js"></script>

…or the script:

<script src="mathup.iife.js"></script>

Usage

const expression = "1+1 = 2";
const options = {};  // optional
const mathml = mathup(expression, options);

mathml.toString();
// => "<math><mrow><mn>1</mn><mo>+</mo><mn>1</mn></mrow><mo>=</mo><mn>2</mn></math>"

const mathNode = mathml.toDOM();
// => [object MathMLElement]

// Update existing <math> node in place
mathup("3-2 = 1", { bare: true }).updateDOM(mathNode);
Custom Element
<math-up
  display="inline"
  dir="ltr"
  decimal-mark=","
  col-sep=";"
  row-sep=";;"
>
  1+1 = 2
</math-up>
Command Line
npm install -g mathup

mathup [options] -- <expression>

# or from stdin
echo <expression> | mathup [options]

Options (with defaults)

const options = {
  decimalMark: ".",   // -m,  --decimalmark="."
  colSep: ",",        // -c,  --colsep=","
  rowSep: ";",        // -r,  --rowsep=";"
  display: "inline",  // -d,  --display
  dir: "ltr",         //      --rtl
  bare: false,        // -b,  --bare
}

Reference

See here

Easy MathML authoring tool with a quick to write syntax

This package exposes a single function mathup that intuitively takes simple mathematical expressions—written in a markup language inspired by AsciiMath—and outputs structured MathML.

You can use it on the command line or on the server as an npm package, or in the browser by including the script source. In the browser, you choose how to parse the math in your document—by looking hard for any math-y substrings, parsing all expressions wrapped in $$, or using some other excellent tools out there that does it for you. And you can choose what to do with the output as well—piping it to another program, inject it streight to the DOM, or just logging it to the console.

Why not just use MathJax?

MathJax is an excellent tool that you can safely use if all you want to do is include complex mathematical expressions in a document. However, MathJax is a complex piece of software that does a great deal more than just translate simple expression into structured form, and if that is all you want to do, then MathJax is definitely overkill. Mathup promises to be a lot faster (by doing less) then MathJax. While MathJax will search for expressions, parse them, translate and render them. Mathup only parses and translates them, and let the browser do the rendering.

Why AsciiMath / Why not TeΧ?

I wrote this tool, because I wanted to be able to author mathematical expressions quickly, with no overhead (imagine 1/2 instead of \frac{1}{2}). TeΧ expressions can easily become verbose and annoying to write (especially on keyboards with complex access to the \ , {, and } keys). However, the purpose of this package is not to give people complete control over MathML in a non-verbose way, the purpose is to make it simple for people to write simple expression. Of course I’ll try to give as much expressive power as possible in the way, but I won’t promise to make all complex things possible.

If you want full support of MathML, and don’t want to write all those tags perhaps you should look for another tool. There are other great efforts to enable people to author MathML in TeX format, take a look at TeXZilla for example.

Testing

Run the test suites with:

npm test

As for manual and visual tests, if you are running node 13 or newer, you don’t need to compile between edit and run as the code is written without transpilation in mind. The code works in both browsers and node without any transcompilation.

For a simple test do:

./bin/mathup.js -- 'my expression'

You can open a playground and test cases on http://localhost:8000/demo by running:

npm run server

mathup's People

Contributors

runarberg avatar dependabot[bot] avatar lukasbestle avatar shellyln avatar tie avatar littlehelicase avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.