@@ -24,26 +24,58 @@ import mathup from "mathup";
2424
2525##### Client #####
2626
27- Download
28- [ full] ( https://raw.githubusercontent.com/runarberg/mathup/gh-pages/dist/mathup.js )
29- or
30- [ minified] ( https://raw.githubusercontent.com/runarberg/mathup/gh-pages/dist/mathup.min.js )
31- and include the script file
27+ Download one of the [ released assets] ( https://github.com/runarberg/mathup/releases )
28+ and include the ** module** :
3229
3330``` html
34- <script src =" mathup.js" ></script >
31+ <script type =" module" src =" mathup.mjs" ></script >
32+ ```
33+
34+ …the ** custom element** :
35+
36+ ``` html
37+ <script type =" module" src =" math-up-element.mjs" ></script >
38+ ```
39+
40+ …or the ** script** :
41+
42+ ``` html
43+ <script src =" mathup.iife.mjs" ></script >
3544```
3645
3746#### Usage ####
3847
3948``` js
40- var mathml = mathup (input [, options]);
49+ const expression = " 1+1 = 2" ;
50+ const options = {}; // optional
51+ const mathml = mathup (expression, options);
52+
53+ mathml .toString ();
54+ // => "<math><mrow><mn>1</mn><mo>+</mo><mn>1</mn></mrow><mo>=</mo><mn>2</mn></math>"
4155
42- console .log (mathml .toString ());
43- document .body .appendChild (mathml .toDOM ());
56+ const mathNode = mathml .toDOM ();
57+ // => [object MathMLElement]
58+
59+ // Update existing <math> node in place
60+ mathup (" 3-2 = 1" , { bare: true }).updateDOM (mathNode);
4461```
4562
46- Or on the command line
63+
64+ ##### Custom Element #####
65+
66+ ``` html
67+ <math-up
68+ display =" inline"
69+ dir =" ltr"
70+ decimal-mark =" ,"
71+ col-sep =" ;"
72+ row-sep =" ;;"
73+ >
74+ 1+1 = 2
75+ </math-up >
76+ ```
77+
78+ ##### Command Line #####
4779
4880``` bash
4981npm install -g mathup
@@ -56,18 +88,14 @@ echo <expression> | mathup [options]
5688
5789#### Options (with defaults) ####
5890
59- And cli options as inline comments
60-
6191``` js
62- import mathup from " mathup" ;
63-
6492const options = {
65- decimalMark: " ." , // -m, --decimalmark="."
66- colSep: " ," , // -c, --colsep=","
67- rowSep: " ;" , // -r, --rowsep=";"
68- display: " inline" , // -d, --display
69- dir: " ltr" , // --rtl
70- bare: false , // -b, --bare
93+ decimalMark: " ." , // -m, --decimalmark="."
94+ colSep: " ," , // -c, --colsep=","
95+ rowSep: " ;" , // -r, --rowsep=";"
96+ display: " inline" , // -d, --display
97+ dir: " ltr" , // --rtl
98+ bare: false , // -b, --bare
7199}
72100```
73101
@@ -81,19 +109,18 @@ Easy MathML authoring tool with a quick to write syntax
81109-------------------------------------------------------
82110
83111This package exposes a single function ` mathup ` that intuitively takes
84- simple mathematical expressions written in a dialog similar to
85- [ * AsciiMath* ] ( http://asciimath.org/ ) , and outputs verbose and ugly
86- (but structured) [ * MathML* ] ( http://www.w3.org/Math/ ) . That is all it
87- does.
112+ simple mathematical expressions—written in a markup language inspired
113+ by [ * AsciiMath* ] ( http://asciimath.org/ ) —and outputs structured
114+ [ * MathML* ] ( http://www.w3.org/Math/ ) .
88115
89116You can use it on the command line or on the server as an
90- [ npm] ( http ://npmjs.com/ ) package, or in the browser by including the
117+ [ npm] ( https ://npmjs.com) package, or in the browser by including the
91118script source. In the browser, you choose how to parse the math in
92- your document ( by looking hard for any math-y substrings, parsing all
93- expressions wrapped in ` $ ` …` $ ` , or using some other excellent tools
94- out there that does it for you) . And you can choose what to do with
95- the output as well ( piping it to another program, calling your
96- favorite DOM parser to inject it , or just logging it to the console) .
119+ your document— by looking hard for any math-y substrings, parsing all
120+ expressions wrapped in ` $ ` …` $ ` , or using some other excellent tools out
121+ there that does it for you. And you can choose what to do with the
122+ output as well— piping it to another program, inject it streight to the
123+ DOM, or just logging it to the console.
97124
98125
99126Why not just use * MathJax* ?
@@ -122,12 +149,13 @@ Why AsciiMath / Why not TeΧ?
122149I wrote this tool, because I wanted to be able to author mathematical
123150expressions quickly, with no overhead (imagine ` 1/2 ` instead of
124151` \frac{1}{2} ` ). TeΧ expressions can easily become verbose and annoying
125- to write (especially on keyboards with complex access to the ` \ ` , ` { ` ,
126- and ` } ` keys). However, the purpose of this package is * not* to give
127- people complete control over MathML in a non-verbose way, the purpose
128- is to make it simple for people to write simple expression. Of course
129- I’ll try to give as much expressive power as possible in the way, but
130- I won’t promise to make all complex things possible.
152+ to write (especially on keyboards with complex access to the
153+ <kbd >\< /kbd>, <kbd >{</kbd >, and <kbd >}</kbd > keys). However, the
154+ purpose of this package is * not* to give people complete control over
155+ MathML in a non-verbose way, the purpose is to make it simple for
156+ people to write simple expression. Of course I’ll try to give as much
157+ expressive power as possible in the way, but I won’t promise to make
158+ all complex things possible.
131159
132160If you want full support of MathML, and don’t want to write all those
133161tags perhaps you should look for another tool. There are other great
@@ -155,8 +183,10 @@ For a simple test do:
155183./bin/mathup.mjs -- ' my expression'
156184```
157185
158- You can open a playground and a demo on < http://localhost:8000/demo >
159- or the documentation on < http://localhost:8000/docs > with:
186+ You can open a
187+ [ playground] ( http://localhost:8000/demo/playground.html ) and [ test
188+ cases] ( http://localhost:8000/demo/test-cases.html ) on
189+ < http://localhost:8000/demo > by running:
160190
161191``` bash
162192npm run server
0 commit comments