asciimathml-ts 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,6 +3,12 @@ asciimathml-ts
3
3
 
4
4
  This is a quick-and-dirty port of ASCIIMathML.js into TS and NPM.
5
5
 
6
+ Update jan.2026: updated tsconfig to output ES6 module and added an example. Check the original, there seems to be new feature being added.
7
+
8
+ ----
9
+
10
+ Original Readme feb.2021
11
+
6
12
  Disclaimer: I'm the wrong guy to build this, I am just on day one of learning ASCIIMath. But the existing library didn't meet my needs, so I ran it through TS and posted it on NPM.
7
13
 
8
14
  It's not completely clean. There is some confusion in the original code between DocumentFragments and strings that prevents strict TS typechecking. I'll come back
@@ -14,7 +20,7 @@ ASCIIMathML translates from ASCIIMath to MathML. [Check this out.](http://www1.
14
20
 
15
21
  As I write this, MathML is only supported in FireFox and Opera, but it looks as if Chrome support is [on the horizon.](https://mathml.igalia.com/)
16
22
 
17
- The original ASCIIMathML is here: [https://github.com/asciimath/asciimathml](https://github.com/asciimath/asciimathml)
23
+ The original ASCIIMathML is here: [https://github.com/asciimath/asciimathml](https://github.com/asciimath/asciimathml)
18
24
 
19
25
 
20
26
 
@@ -27,7 +33,7 @@ color and fonts.
27
33
 
28
34
  ## Usage
29
35
  ```
30
- import {AsciiMath} from 'ASCIIMathML'
36
+ import {AsciiMath} from 'ASCIIMathML-ts'
31
37
 
32
38
  let a = new AsciiMath()
33
39
 
@@ -1,4 +1,4 @@
1
- declare type AMSymbol = {
1
+ type AMSymbol = {
2
2
  input: string;
3
3
  tag: 'mi' | 'mo' | 'mn' | 'mroot' | 'mfrac' | 'msup' | 'msub' | 'mover' | 'mtext' | 'msqrt' | 'munder' | 'mstyle' | 'menclose' | 'mrow';
4
4
  output: string;
@@ -13,7 +13,7 @@ declare type AMSymbol = {
13
13
  atval?: "bold" | "sans-serif" | "double-struck" | "script" | "fraktur" | "monospace";
14
14
  codes?: string[];
15
15
  };
16
- declare type Tag = 'div' | 'p' | 'span' | 'body' | 'a';
16
+ type Tag = 'div' | 'p' | 'span' | 'body' | 'a';
17
17
  /** convert an AsciiMath statement to MathML */
18
18
  export declare class AsciiMath {
19
19
  noMathML: boolean;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /*
3
2
  ASCIIMathML.ts
4
3
  ==============
@@ -47,32 +46,30 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
46
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
48
47
  THE SOFTWARE.
49
48
  */
50
- Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.AsciiMath = void 0;
52
49
  // or another family (e.g. "arial")
53
- var automathrecognize = false; // writing "amath" on page makes this true
54
- var checkForMathML = true; // check if browser can display MathML
55
- var notifyIfNoMathML = true; // display note at top if no MathML capability
56
- var alertIfNoMathML = false; // show alert box if no MathML capability
57
- var translateOnLoad = true; // set to false to do call translators from js
58
- var translateASCIIMath = true; // false to preserve `..`
59
- var displaystyle = true; // puts limits above and below large operators
60
- var showasciiformulaonhover = true; // helps students learn ASCIIMath
61
- var decimalsign = "."; // if "," then when writing lists or matrices put
50
+ let automathrecognize = false; // writing "amath" on page makes this true
51
+ let checkForMathML = true; // check if browser can display MathML
52
+ let notifyIfNoMathML = true; // display note at top if no MathML capability
53
+ let alertIfNoMathML = false; // show alert box if no MathML capability
54
+ let translateOnLoad = true; // set to false to do call translators from js
55
+ let translateASCIIMath = true; // false to preserve `..`
56
+ let displaystyle = true; // puts limits above and below large operators
57
+ let showasciiformulaonhover = true; // helps students learn ASCIIMath
58
+ let decimalsign = "."; // if "," then when writing lists or matrices put
62
59
  //a space after the "," like `(1, 2)` not `(1,2)`
63
- var fixphi = true; //false to return to legacy phi/varphi mapping
60
+ let fixphi = true; //false to return to legacy phi/varphi mapping
64
61
  // character lists for Mozilla/Netscape fonts
65
- var AMcal = ["\uD835\uDC9C", "\u212C", "\uD835\uDC9E", "\uD835\uDC9F", "\u2130", "\u2131", "\uD835\uDCA2", "\u210B", "\u2110", "\uD835\uDCA5", "\uD835\uDCA6", "\u2112", "\u2133", "\uD835\uDCA9", "\uD835\uDCAA", "\uD835\uDCAB", "\uD835\uDCAC", "\u211B", "\uD835\uDCAE", "\uD835\uDCAF", "\uD835\uDCB0", "\uD835\uDCB1", "\uD835\uDCB2", "\uD835\uDCB3", "\uD835\uDCB4", "\uD835\uDCB5", "\uD835\uDCB6", "\uD835\uDCB7", "\uD835\uDCB8", "\uD835\uDCB9", "\u212F", "\uD835\uDCBB", "\u210A", "\uD835\uDCBD", "\uD835\uDCBE", "\uD835\uDCBF", "\uD835\uDCC0", "\uD835\uDCC1", "\uD835\uDCC2", "\uD835\uDCC3", "\u2134", "\uD835\uDCC5", "\uD835\uDCC6", "\uD835\uDCC7", "\uD835\uDCC8", "\uD835\uDCC9", "\uD835\uDCCA", "\uD835\uDCCB", "\uD835\uDCCC", "\uD835\uDCCD", "\uD835\uDCCE", "\uD835\uDCCF"];
66
- var AMfrk = ["\uD835\uDD04", "\uD835\uDD05", "\u212D", "\uD835\uDD07", "\uD835\uDD08", "\uD835\uDD09", "\uD835\uDD0A", "\u210C", "\u2111", "\uD835\uDD0D", "\uD835\uDD0E", "\uD835\uDD0F", "\uD835\uDD10", "\uD835\uDD11", "\uD835\uDD12", "\uD835\uDD13", "\uD835\uDD14", "\u211C", "\uD835\uDD16", "\uD835\uDD17", "\uD835\uDD18", "\uD835\uDD19", "\uD835\uDD1A", "\uD835\uDD1B", "\uD835\uDD1C", "\u2128", "\uD835\uDD1E", "\uD835\uDD1F", "\uD835\uDD20", "\uD835\uDD21", "\uD835\uDD22", "\uD835\uDD23", "\uD835\uDD24", "\uD835\uDD25", "\uD835\uDD26", "\uD835\uDD27", "\uD835\uDD28", "\uD835\uDD29", "\uD835\uDD2A", "\uD835\uDD2B", "\uD835\uDD2C", "\uD835\uDD2D", "\uD835\uDD2E", "\uD835\uDD2F", "\uD835\uDD30", "\uD835\uDD31", "\uD835\uDD32", "\uD835\uDD33", "\uD835\uDD34", "\uD835\uDD35", "\uD835\uDD36", "\uD835\uDD37"];
67
- var AMbbb = ["\uD835\uDD38", "\uD835\uDD39", "\u2102", "\uD835\uDD3B", "\uD835\uDD3C", "\uD835\uDD3D", "\uD835\uDD3E", "\u210D", "\uD835\uDD40", "\uD835\uDD41", "\uD835\uDD42", "\uD835\uDD43", "\uD835\uDD44", "\u2115", "\uD835\uDD46", "\u2119", "\u211A", "\u211D", "\uD835\uDD4A", "\uD835\uDD4B", "\uD835\uDD4C", "\uD835\uDD4D", "\uD835\uDD4E", "\uD835\uDD4F", "\uD835\uDD50", "\u2124", "\uD835\uDD52", "\uD835\uDD53", "\uD835\uDD54", "\uD835\uDD55", "\uD835\uDD56", "\uD835\uDD57", "\uD835\uDD58", "\uD835\uDD59", "\uD835\uDD5A", "\uD835\uDD5B", "\uD835\uDD5C", "\uD835\uDD5D", "\uD835\uDD5E", "\uD835\uDD5F", "\uD835\uDD60", "\uD835\uDD61", "\uD835\uDD62", "\uD835\uDD63", "\uD835\uDD64", "\uD835\uDD65", "\uD835\uDD66", "\uD835\uDD67", "\uD835\uDD68", "\uD835\uDD69", "\uD835\uDD6A", "\uD835\uDD6B"];
62
+ let AMcal = ["\uD835\uDC9C", "\u212C", "\uD835\uDC9E", "\uD835\uDC9F", "\u2130", "\u2131", "\uD835\uDCA2", "\u210B", "\u2110", "\uD835\uDCA5", "\uD835\uDCA6", "\u2112", "\u2133", "\uD835\uDCA9", "\uD835\uDCAA", "\uD835\uDCAB", "\uD835\uDCAC", "\u211B", "\uD835\uDCAE", "\uD835\uDCAF", "\uD835\uDCB0", "\uD835\uDCB1", "\uD835\uDCB2", "\uD835\uDCB3", "\uD835\uDCB4", "\uD835\uDCB5", "\uD835\uDCB6", "\uD835\uDCB7", "\uD835\uDCB8", "\uD835\uDCB9", "\u212F", "\uD835\uDCBB", "\u210A", "\uD835\uDCBD", "\uD835\uDCBE", "\uD835\uDCBF", "\uD835\uDCC0", "\uD835\uDCC1", "\uD835\uDCC2", "\uD835\uDCC3", "\u2134", "\uD835\uDCC5", "\uD835\uDCC6", "\uD835\uDCC7", "\uD835\uDCC8", "\uD835\uDCC9", "\uD835\uDCCA", "\uD835\uDCCB", "\uD835\uDCCC", "\uD835\uDCCD", "\uD835\uDCCE", "\uD835\uDCCF"];
63
+ let AMfrk = ["\uD835\uDD04", "\uD835\uDD05", "\u212D", "\uD835\uDD07", "\uD835\uDD08", "\uD835\uDD09", "\uD835\uDD0A", "\u210C", "\u2111", "\uD835\uDD0D", "\uD835\uDD0E", "\uD835\uDD0F", "\uD835\uDD10", "\uD835\uDD11", "\uD835\uDD12", "\uD835\uDD13", "\uD835\uDD14", "\u211C", "\uD835\uDD16", "\uD835\uDD17", "\uD835\uDD18", "\uD835\uDD19", "\uD835\uDD1A", "\uD835\uDD1B", "\uD835\uDD1C", "\u2128", "\uD835\uDD1E", "\uD835\uDD1F", "\uD835\uDD20", "\uD835\uDD21", "\uD835\uDD22", "\uD835\uDD23", "\uD835\uDD24", "\uD835\uDD25", "\uD835\uDD26", "\uD835\uDD27", "\uD835\uDD28", "\uD835\uDD29", "\uD835\uDD2A", "\uD835\uDD2B", "\uD835\uDD2C", "\uD835\uDD2D", "\uD835\uDD2E", "\uD835\uDD2F", "\uD835\uDD30", "\uD835\uDD31", "\uD835\uDD32", "\uD835\uDD33", "\uD835\uDD34", "\uD835\uDD35", "\uD835\uDD36", "\uD835\uDD37"];
64
+ let AMbbb = ["\uD835\uDD38", "\uD835\uDD39", "\u2102", "\uD835\uDD3B", "\uD835\uDD3C", "\uD835\uDD3D", "\uD835\uDD3E", "\u210D", "\uD835\uDD40", "\uD835\uDD41", "\uD835\uDD42", "\uD835\uDD43", "\uD835\uDD44", "\u2115", "\uD835\uDD46", "\u2119", "\u211A", "\u211D", "\uD835\uDD4A", "\uD835\uDD4B", "\uD835\uDD4C", "\uD835\uDD4D", "\uD835\uDD4E", "\uD835\uDD4F", "\uD835\uDD50", "\u2124", "\uD835\uDD52", "\uD835\uDD53", "\uD835\uDD54", "\uD835\uDD55", "\uD835\uDD56", "\uD835\uDD57", "\uD835\uDD58", "\uD835\uDD59", "\uD835\uDD5A", "\uD835\uDD5B", "\uD835\uDD5C", "\uD835\uDD5D", "\uD835\uDD5E", "\uD835\uDD5F", "\uD835\uDD60", "\uD835\uDD61", "\uD835\uDD62", "\uD835\uDD63", "\uD835\uDD64", "\uD835\uDD65", "\uD835\uDD66", "\uD835\uDD67", "\uD835\uDD68", "\uD835\uDD69", "\uD835\uDD6A", "\uD835\uDD6B"];
68
65
  /*let AMcal = [0xEF35,0x212C,0xEF36,0xEF37,0x2130,0x2131,0xEF38,0x210B,0x2110,0xEF39,0xEF3A,0x2112,0x2133,0xEF3B,0xEF3C,0xEF3D,0xEF3E,0x211B,0xEF3F,0xEF40,0xEF41,0xEF42,0xEF43,0xEF44,0xEF45,0xEF46];
69
66
  let AMfrk = [0xEF5D,0xEF5E,0x212D,0xEF5F,0xEF60,0xEF61,0xEF62,0x210C,0x2111,0xEF63,0xEF64,0xEF65,0xEF66,0xEF67,0xEF68,0xEF69,0xEF6A,0x211C,0xEF6B,0xEF6C,0xEF6D,0xEF6E,0xEF6F,0xEF70,0xEF71,0x2128];
70
67
  let AMbbb = [0xEF8C,0xEF8D,0x2102,0xEF8E,0xEF8F,0xEF90,0xEF91,0x210D,0xEF92,0xEF93,0xEF94,0xEF95,0xEF96,0x2115,0xEF97,0x2119,0x211A,0x211D,0xEF98,0xEF99,0xEF9A,0xEF9B,0xEF9C,0xEF9D,0xEF9E,0x2124];*/
71
- var CONST = 0, UNARY = 1, BINARY = 2, INFIX = 3, LEFTBRACKET = 4, RIGHTBRACKET = 5, SPACE = 6, UNDEROVER = 7, DEFINITION = 8, LEFTRIGHT = 9, TEXT = 10, BIG = 11, LONG = 12, STRETCHY = 13, MATRIX = 14, UNARYUNDEROVER = 15; // token types
72
- var AMquote = { input: "\"", tag: "mtext", output: "mbox", tex: null, ttype: TEXT };
68
+ let CONST = 0, UNARY = 1, BINARY = 2, INFIX = 3, LEFTBRACKET = 4, RIGHTBRACKET = 5, SPACE = 6, UNDEROVER = 7, DEFINITION = 8, LEFTRIGHT = 9, TEXT = 10, BIG = 11, LONG = 12, STRETCHY = 13, MATRIX = 14, UNARYUNDEROVER = 15; // token types
69
+ let AMquote = { input: "\"", tag: "mtext", output: "mbox", tex: null, ttype: TEXT };
73
70
  /** convert an AsciiMath statement to MathML */
74
- var AsciiMath = /** @class */ (function () {
75
- function AsciiMath() {
71
+ export class AsciiMath {
72
+ constructor() {
76
73
  this.noMathML = false;
77
74
  this.translated = false;
78
75
  this.latex = false;
@@ -88,9 +85,9 @@ var AsciiMath = /** @class */ (function () {
88
85
  this.init();
89
86
  }
90
87
  /** Add a stylesheet, replacing any previous custom stylesheet (adapted from TW) */
91
- AsciiMath.prototype.setStylesheet = function (s) {
92
- var id = "AMMLcustomStyleSheet";
93
- var n = document.getElementById(id);
88
+ setStylesheet(s) {
89
+ let id = "AMMLcustomStyleSheet";
90
+ let n = document.getElementById(id);
94
91
  // if (document.createStyleSheet) { // tbtb
95
92
  // // Test for IE's non-standard createStyleSheet method
96
93
  // if (n)
@@ -109,9 +106,9 @@ var AsciiMath = /** @class */ (function () {
109
106
  document.getElementsByTagName("head")[0].appendChild(n);
110
107
  }
111
108
  // }
112
- };
113
- AsciiMath.prototype.init = function () {
114
- var msg, warnings = new Array();
109
+ }
110
+ init() {
111
+ let msg, warnings = new Array();
115
112
  if (document.getElementById == null) {
116
113
  alert("This webpage requires a recent browser such as Mozilla Firefox");
117
114
  return null;
@@ -123,8 +120,8 @@ var AsciiMath = /** @class */ (function () {
123
120
  if (!this.noMathML)
124
121
  this.initSymbols();
125
122
  return true;
126
- };
127
- AsciiMath.prototype.checkMathML = function () {
123
+ }
124
+ checkMathML() {
128
125
  if (navigator.appName.slice(0, 8) == "Netscape")
129
126
  if (navigator.appVersion.slice(0, 1) >= "5")
130
127
  this.noMathML = null;
@@ -144,21 +141,21 @@ var AsciiMath = /** @class */ (function () {
144
141
  this.noMathML = true;
145
142
  //noMathML = true; //uncomment to check
146
143
  if (this.noMathML && notifyIfNoMathML) {
147
- var msg = "To view the ASCIIMathML notation use Internet Explorer + MathPlayer or Mozilla Firefox 2.0 or later.";
144
+ let msg = "To view the ASCIIMathML notation use Internet Explorer + MathPlayer or Mozilla Firefox 2.0 or later.";
148
145
  if (alertIfNoMathML)
149
146
  alert(msg);
150
147
  else
151
148
  return msg;
152
149
  }
153
- };
154
- AsciiMath.prototype.hideWarning = function () {
155
- var body = document.getElementsByTagName("body")[0];
150
+ }
151
+ hideWarning() {
152
+ let body = document.getElementsByTagName("body")[0];
156
153
  body.removeChild(document.getElementById('AMMLwarningBox'));
157
154
  body.onclick = null;
158
- };
159
- AsciiMath.prototype.displayWarnings = function (warnings) {
160
- var i, frag, nd = this.createElementXHTML("div");
161
- var body = document.getElementsByTagName("body")[0];
155
+ }
156
+ displayWarnings(warnings) {
157
+ let i, frag, nd = this.createElementXHTML("div");
158
+ let body = document.getElementsByTagName("body")[0];
162
159
  body.onclick = this.hideWarning;
163
160
  nd.id = 'AMMLwarningBox';
164
161
  for (i = 0; i < warnings.length; i++) {
@@ -169,7 +166,7 @@ var AsciiMath = /** @class */ (function () {
169
166
  }
170
167
  nd.appendChild(this.createElementXHTML("p"));
171
168
  nd.appendChild(document.createTextNode("For instructions see the "));
172
- var an = this.createElementXHTML("a");
169
+ let an = this.createElementXHTML("a");
173
170
  an.appendChild(document.createTextNode("ASCIIMathML"));
174
171
  an.setAttribute("href", "http://asciimath.org");
175
172
  nd.appendChild(an);
@@ -179,49 +176,49 @@ var AsciiMath = /** @class */ (function () {
179
176
  an.appendChild(document.createTextNode('(click anywhere to close this warning)'));
180
177
  nd.appendChild(an);
181
178
  body.insertBefore(nd, body.childNodes[0]);
182
- };
179
+ }
183
180
  /** Find and translate all math on a page. if spanclassAM is provided then it
184
181
  * is the tag to look for. Perhaps 'span' is a good value. If it is NOT
185
182
  * provided, then we will look for AMDelimiter1 (by default a backtick)
186
183
  */
187
- AsciiMath.prototype.translate = function (spanclassAM) {
184
+ translate(spanclassAM) {
188
185
  if (!this.translated) { // run this only once
189
186
  this.translated = true;
190
- var body = document.getElementsByTagName("body")[0];
187
+ let body = document.getElementsByTagName("body")[0];
191
188
  this.AMprocessNode(body, false, spanclassAM);
192
189
  }
193
- };
194
- AsciiMath.prototype.createElementXHTML = function (t) {
190
+ }
191
+ createElementXHTML(t) {
195
192
  return document.createElementNS("http://www.w3.org/1999/xhtml", t);
196
- };
197
- AsciiMath.prototype.AMcreateElementMathML = function (t) {
193
+ }
194
+ AMcreateElementMathML(t) {
198
195
  return document.createElementNS(this.AMmathml, t);
199
- };
200
- AsciiMath.prototype.createMmlNode = function (t, frag) {
201
- var node;
196
+ }
197
+ createMmlNode(t, frag) {
198
+ let node;
202
199
  node = document.createElementNS(this.AMmathml, t);
203
200
  if (frag)
204
201
  node.appendChild(frag);
205
202
  return node;
206
- };
207
- AsciiMath.prototype.newcommand = function (oldstr, newstr) {
203
+ }
204
+ newcommand(oldstr, newstr) {
208
205
  this.AMSymbols.push({ input: oldstr, tag: "mo", output: newstr, tex: null, ttype: DEFINITION });
209
206
  this.refreshSymbols();
210
- };
211
- AsciiMath.prototype.newsymbol = function (symbolobj) {
207
+ }
208
+ newsymbol(symbolobj) {
212
209
  this.AMSymbols.push(symbolobj);
213
210
  this.refreshSymbols();
214
- };
215
- AsciiMath.prototype.compareNames = function (s1, s2) {
211
+ }
212
+ compareNames(s1, s2) {
216
213
  if (s1.input > s2.input)
217
214
  return 1;
218
215
  else
219
216
  return -1;
220
- };
221
- AsciiMath.prototype.initSymbols = function () {
222
- var i;
217
+ }
218
+ initSymbols() {
219
+ let i;
223
220
  this.loadAMSymbols();
224
- var symlen = this.AMSymbols.length;
221
+ let symlen = this.AMSymbols.length;
225
222
  for (i = 0; i < symlen; i++) {
226
223
  if (this.AMSymbols[i].tex) {
227
224
  this.AMSymbols.push({
@@ -233,32 +230,32 @@ var AsciiMath = /** @class */ (function () {
233
230
  }
234
231
  }
235
232
  this.refreshSymbols();
236
- };
237
- AsciiMath.prototype.refreshSymbols = function () {
233
+ }
234
+ refreshSymbols() {
238
235
  this.AMSymbols.sort(this.compareNames);
239
- for (var i = 0; i < this.AMSymbols.length; i++)
236
+ for (let i = 0; i < this.AMSymbols.length; i++)
240
237
  this.AMnames[i] = this.AMSymbols[i].input;
241
- };
242
- AsciiMath.prototype.define = function (oldstr, newstr) {
238
+ }
239
+ define(oldstr, newstr) {
243
240
  this.AMSymbols.push({ input: oldstr, tag: "mo", output: newstr, tex: null, ttype: DEFINITION });
244
241
  this.refreshSymbols(); // this may be a problem if many symbols are defined!
245
- };
246
- AsciiMath.prototype.AMremoveCharsAndBlanks = function (str, n) {
242
+ }
243
+ AMremoveCharsAndBlanks(str, n) {
247
244
  //remove n characters and any following blanks
248
- var st;
245
+ let st;
249
246
  if (str.charAt(n) == "\\" && str.charAt(n + 1) != "\\" && str.charAt(n + 1) != " ")
250
247
  st = str.slice(n + 1);
251
248
  else
252
249
  st = str.slice(n);
253
- var i; // tbtb must NOT be defined in the for loop, goes out of scope
250
+ let i; // tbtb must NOT be defined in the for loop, goes out of scope
254
251
  for (i = 0; i < st.length && st.charCodeAt(i) <= 32; i = i + 1) { }
255
252
  return st.slice(i); // tbtb ?? this isn't valid TS, not sure what it means in JS
256
- };
257
- AsciiMath.prototype.position = function (arr, str, n) {
253
+ }
254
+ position(arr, str, n) {
258
255
  // return position >=n where str appears or would be inserted
259
256
  // assumes arr is sorted
260
257
  if (n == 0) {
261
- var h = void 0, m = void 0;
258
+ let h, m;
262
259
  n = -1;
263
260
  h = arr.length;
264
261
  while (n + 1 < h) {
@@ -271,22 +268,22 @@ var AsciiMath = /** @class */ (function () {
271
268
  return h;
272
269
  }
273
270
  else {
274
- var i = void 0;
271
+ let i;
275
272
  for (i = n; i < arr.length && arr[i] < str; i++) { } // stops when it stops
276
273
  return i; // i=arr.length || arr[i]>=str
277
274
  }
278
- };
279
- AsciiMath.prototype.AMgetSymbol = function (str) {
275
+ }
276
+ AMgetSymbol(str) {
280
277
  //return maximal initial substring of str that appears in names
281
278
  //return null if there is none
282
- var k = 0; //new pos
283
- var j = 0; //old pos
284
- var mk; //match pos
285
- var st;
286
- var tagst;
287
- var match = "";
288
- var more = true;
289
- for (var i = 1; i <= str.length && more; i++) {
279
+ let k = 0; //new pos
280
+ let j = 0; //old pos
281
+ let mk; //match pos
282
+ let st;
283
+ let tagst;
284
+ let match = "";
285
+ let more = true;
286
+ for (let i = 1; i <= str.length && more; i++) {
290
287
  st = str.slice(0, i); //initial substring of length i
291
288
  j = k;
292
289
  k = this.position(this.AMnames, st, j);
@@ -306,7 +303,7 @@ var AsciiMath = /** @class */ (function () {
306
303
  this.AMcurrentSymbol = CONST;
307
304
  k = 1;
308
305
  st = str.slice(0, 1);
309
- var integ = true;
306
+ let integ = true;
310
307
  while ("0" <= st && st <= "9" && k <= str.length) {
311
308
  st = str.slice(k, k + 1);
312
309
  k++;
@@ -336,9 +333,9 @@ var AsciiMath = /** @class */ (function () {
336
333
  return { input: st, tag: tagst, output: st, tex: null, ttype: UNARY, func: true };
337
334
  }
338
335
  return { input: st, tag: tagst, output: st, tex: null, ttype: CONST };
339
- };
340
- AsciiMath.prototype.AMremoveBrackets = function (node) {
341
- var st;
336
+ }
337
+ AMremoveBrackets(node) {
338
+ let st;
342
339
  if (!node.hasChildNodes()) {
343
340
  return;
344
341
  }
@@ -355,7 +352,7 @@ var AsciiMath = /** @class */ (function () {
355
352
  if (st == ")" || st == "]" || st == "}")
356
353
  node.removeChild(node.lastChild);
357
354
  }
358
- };
355
+ }
359
356
  /*Parsing ASCII math expressions with the following grammar
360
357
  v ::= [A-Za-z] | greek letters | numbers | other constant symbols
361
358
  u ::= sqrt | text | bb | other unary symbols for font commands
@@ -366,8 +363,8 @@ var AsciiMath = /** @class */ (function () {
366
363
  I ::= S_S | S^S | S_S^S | S Intermediate expression
367
364
  E ::= IE | I/I Expression
368
365
  Each terminal symbol is translated into a corresponding mathml node.*/
369
- AsciiMath.prototype.AMparseSexpr = function (str) {
370
- var symbol, node, result, i, st, // rightvert = false,
366
+ AMparseSexpr(str) {
367
+ let symbol, node, result, i, st, // rightvert = false,
371
368
  newFrag = document.createDocumentFragment();
372
369
  str = this.AMremoveCharsAndBlanks(str, 0);
373
370
  symbol = this.AMgetSymbol(str); //either a token or a bracket or empty
@@ -467,7 +464,7 @@ var AsciiMath = /** @class */ (function () {
467
464
  }
468
465
  else if (typeof symbol.acc == "boolean" && symbol.acc) { // accent
469
466
  node = this.createMmlNode(symbol.tag, result[0]);
470
- var accnode = this.createMmlNode("mo", document.createTextNode(symbol.output));
467
+ let accnode = this.createMmlNode("mo", document.createTextNode(symbol.output));
471
468
  if (symbol.input == "vec" && ((result[0].nodeName == "mrow" && result[0].childNodes.length == 1
472
469
  && result[0].firstChild.firstChild.nodeValue !== null
473
470
  && result[0].firstChild.firstChild.nodeValue.length == 1) ||
@@ -484,8 +481,8 @@ var AsciiMath = /** @class */ (function () {
484
481
  if (result[0].childNodes[i].nodeName == "mi" || result[0].nodeName == "mi") {
485
482
  st = (result[0].nodeName == "mi" ? result[0].firstChild.nodeValue :
486
483
  result[0].childNodes[i].firstChild.nodeValue);
487
- var newst = ''; // tbtb should be string
488
- for (var j = 0; j < st.length; j++)
484
+ let newst = ''; // tbtb should be string
485
+ for (let j = 0; j < st.length; j++)
489
486
  if (st.charCodeAt(j) > 64 && st.charCodeAt(j) < 91)
490
487
  newst = newst + symbol.codes[st.charCodeAt(j) - 65]; // tbtb newst coerced to string here
491
488
  else if (st.charCodeAt(j) > 96 && st.charCodeAt(j) < 123)
@@ -510,7 +507,7 @@ var AsciiMath = /** @class */ (function () {
510
507
  if (result[0] == null)
511
508
  return [this.createMmlNode("mo", document.createTextNode(symbol.input)), str];
512
509
  this.AMremoveBrackets(result[0]);
513
- var result2 = this.AMparseSexpr(result[1]);
510
+ let result2 = this.AMparseSexpr(result[1]);
514
511
  if (result2[0] == null)
515
512
  return [this.createMmlNode("mo", document.createTextNode(symbol.input)), str];
516
513
  this.AMremoveBrackets(result2[0]);
@@ -579,9 +576,9 @@ var AsciiMath = /** @class */ (function () {
579
576
  return [this.createMmlNode(symbol.tag, //its a constant
580
577
  document.createTextNode(symbol.output)), str];
581
578
  }
582
- };
583
- AsciiMath.prototype.AMparseIexpr = function (str) {
584
- var symbol, sym1, sym2, node, result, underover;
579
+ }
580
+ AMparseIexpr(str) {
581
+ let symbol, sym1, sym2, node, result, underover;
585
582
  str = this.AMremoveCharsAndBlanks(str, 0);
586
583
  sym1 = this.AMgetSymbol(str);
587
584
  result = this.AMparseSexpr(str);
@@ -603,7 +600,7 @@ var AsciiMath = /** @class */ (function () {
603
600
  sym2 = this.AMgetSymbol(str);
604
601
  if (sym2.input == "^") {
605
602
  str = this.AMremoveCharsAndBlanks(str, sym2.input.length);
606
- var res2 = this.AMparseSexpr(str);
603
+ let res2 = this.AMparseSexpr(str);
607
604
  this.AMremoveBrackets(res2[0]);
608
605
  str = res2[1];
609
606
  node = this.createMmlNode((underover ? "munderover" : "msubsup"), node);
@@ -636,9 +633,9 @@ var AsciiMath = /** @class */ (function () {
636
633
  }
637
634
  }
638
635
  return [node, str];
639
- };
640
- AsciiMath.prototype.AMparseExpr = function (str, rightbracket) {
641
- var symbol, node, result, i, newFrag = document.createDocumentFragment();
636
+ }
637
+ AMparseExpr(str, rightbracket) {
638
+ let symbol, node, result, i, newFrag = document.createDocumentFragment();
642
639
  do {
643
640
  str = this.AMremoveCharsAndBlanks(str, 0);
644
641
  result = this.AMparseIexpr(str);
@@ -666,21 +663,21 @@ var AsciiMath = /** @class */ (function () {
666
663
  || this.AMnestingDepth == 0) && symbol != null && symbol.output != "");
667
664
  if (symbol.ttype == RIGHTBRACKET || symbol.ttype == LEFTRIGHT) {
668
665
  // if (AMnestingDepth > 0) AMnestingDepth--;
669
- var len = newFrag.childNodes.length;
666
+ let len = newFrag.childNodes.length;
670
667
  if (len > 0 && newFrag.childNodes[len - 1].nodeName == "mrow"
671
668
  && newFrag.childNodes[len - 1].lastChild
672
669
  && newFrag.childNodes[len - 1].lastChild.firstChild) { //matrix
673
670
  //removed to allow row vectors: //&& len>1 &&
674
671
  //newFrag.childNodes[len-2].nodeName == "mo" &&
675
672
  //newFrag.childNodes[len-2].firstChild.nodeValue == ","
676
- var right = newFrag.childNodes[len - 1].lastChild.firstChild.nodeValue;
673
+ let right = newFrag.childNodes[len - 1].lastChild.firstChild.nodeValue;
677
674
  if (right == ")" || right == "]") {
678
- var left = newFrag.childNodes[len - 1].firstChild.firstChild.nodeValue;
675
+ let left = newFrag.childNodes[len - 1].firstChild.firstChild.nodeValue;
679
676
  if (left == "(" && right == ")" && symbol.output != "}" ||
680
677
  left == "[" && right == "]") {
681
- var pos = []; // positions of commas
682
- var matrix = true;
683
- var m = newFrag.childNodes.length;
678
+ let pos = []; // positions of commas
679
+ let matrix = true;
680
+ let m = newFrag.childNodes.length;
684
681
  for (i = 0; matrix && i < m; i = i + 2) {
685
682
  pos[i] = [];
686
683
  node = newFrag.childNodes[i];
@@ -693,16 +690,16 @@ var AsciiMath = /** @class */ (function () {
693
690
  node.lastChild.firstChild &&
694
691
  node.lastChild.firstChild.nodeValue == right;
695
692
  if (matrix)
696
- for (var j = 0; j < node.childNodes.length; j++)
693
+ for (let j = 0; j < node.childNodes.length; j++)
697
694
  if (node.childNodes[j].firstChild.nodeValue == ",")
698
695
  pos[i][pos[i].length] = j;
699
696
  if (matrix && i > 1)
700
697
  matrix = pos[i].length == pos[i - 2].length;
701
698
  }
702
699
  matrix = matrix && (pos.length > 1 || pos[0].length > 0);
703
- var columnlines = [];
700
+ let columnlines = [];
704
701
  if (matrix) {
705
- var row = void 0, frag = void 0, n = void 0, k = void 0, table = document.createDocumentFragment();
702
+ let row, frag, n, k, table = document.createDocumentFragment();
706
703
  for (i = 0; i < m; i = i + 2) {
707
704
  row = document.createDocumentFragment();
708
705
  frag = document.createDocumentFragment();
@@ -710,7 +707,7 @@ var AsciiMath = /** @class */ (function () {
710
707
  n = node.childNodes.length;
711
708
  k = 0;
712
709
  node.removeChild(node.firstChild); //remove (
713
- for (var j = 1; j < n - 1; j++) {
710
+ for (let j = 1; j < n - 1; j++) {
714
711
  if (typeof pos[i][k] != "undefined" && j == pos[i][k]) {
715
712
  node.removeChild(node.firstChild); //remove ,
716
713
  if (node.firstChild.nodeName == "mrow" && node.firstChild.childNodes.length == 1 &&
@@ -759,20 +756,20 @@ var AsciiMath = /** @class */ (function () {
759
756
  }
760
757
  }
761
758
  return [newFrag, str];
762
- };
759
+ }
763
760
  /** Convert a single string to an HTML Element ready for insertion.
764
761
  * let a = new AsciiMath()
765
762
  * let eqn = 'sum_(i=1)^n i^3=((n(n+1))/2)^2'
766
763
  * document.getElementById('insertMathHere').appendChild(a.parseMath(eqn))
767
764
  */
768
- AsciiMath.prototype.parseMath = function (str) {
765
+ parseMath(str) {
769
766
  this.AMnestingDepth = 0;
770
767
  //some basic cleanup for dealing with stuff editors like TinyMCE adds
771
768
  str = str.replace(/&nbsp;/g, "");
772
769
  str = str.replace(/&gt;/g, ">");
773
770
  str = str.replace(/&lt;/g, "<");
774
- var frag = this.AMparseExpr(str.replace(/^\s+/g, ""), false)[0];
775
- var node = this.createMmlNode("mstyle", frag);
771
+ let frag = this.AMparseExpr(str.replace(/^\s+/g, ""), false)[0];
772
+ let node = this.createMmlNode("mstyle", frag);
776
773
  if (this.mathcolor != "")
777
774
  node.setAttribute("mathcolor", this.mathcolor);
778
775
  if (this.mathfontsize != "") {
@@ -789,18 +786,18 @@ var AsciiMath = /** @class */ (function () {
789
786
  if (showasciiformulaonhover) //fixed by djhsu so newline
790
787
  node.setAttribute("title", str.replace(/\s+/g, " ")); //does not show in Gecko
791
788
  return node;
792
- };
793
- AsciiMath.prototype.strarr2docFrag = function (arr, linebreaks) {
794
- var newFrag = document.createDocumentFragment();
795
- var expr = false;
796
- for (var i = 0; i < arr.length; i++) {
789
+ }
790
+ strarr2docFrag(arr, linebreaks) {
791
+ let newFrag = document.createDocumentFragment();
792
+ let expr = false;
793
+ for (let i = 0; i < arr.length; i++) {
797
794
  if (expr)
798
795
  newFrag.appendChild(this.parseMath(arr[i]));
799
796
  else {
800
- var arri = (linebreaks ? arr[i].split("\n\n") : [arr[i]]);
797
+ let arri = (linebreaks ? arr[i].split("\n\n") : [arr[i]]);
801
798
  newFrag.appendChild(this.createElementXHTML("span").
802
799
  appendChild(document.createTextNode(arri[0])));
803
- for (var j = 1; j < arri.length; j++) {
800
+ for (let j = 1; j < arri.length; j++) {
804
801
  newFrag.appendChild(this.createElementXHTML("p"));
805
802
  newFrag.appendChild(this.createElementXHTML("span").
806
803
  appendChild(document.createTextNode(arri[j])));
@@ -809,23 +806,23 @@ var AsciiMath = /** @class */ (function () {
809
806
  expr = !expr;
810
807
  }
811
808
  return newFrag;
812
- };
813
- AsciiMath.prototype.AMautomathrec = function (str) {
809
+ }
810
+ AMautomathrec(str) {
814
811
  //formula is a space (or start of str) followed by a maximal sequence of *two* or more tokens, possibly separated by runs of digits and/or space.
815
812
  //tokens are single letters (except a, A, I) and ASCIIMathML tokens
816
- var texcommand = "\\\\[a-zA-Z]+|\\\\\\s|";
817
- var ambigAMtoken = "\\b(?:oo|lim|ln|int|oint|del|grad|aleph|prod|prop|sinh|cosh|tanh|cos|sec|pi|tt|fr|sf|sube|supe|sub|sup|det|mod|gcd|lcm|min|max|vec|ddot|ul|chi|eta|nu|mu)(?![a-z])|";
818
- var englishAMtoken = "\\b(?:sum|ox|log|sin|tan|dim|hat|bar|dot)(?![a-z])|";
819
- var secondenglishAMtoken = "|\\bI\\b|\\bin\\b|\\btext\\b"; // took if and or not out
820
- var simpleAMtoken = "NN|ZZ|QQ|RR|CC|TT|AA|EE|sqrt|dx|dy|dz|dt|xx|vv|uu|nn|bb|cc|csc|cot|alpha|beta|delta|Delta|epsilon|gamma|Gamma|kappa|lambda|Lambda|omega|phi|Phi|Pi|psi|Psi|rho|sigma|Sigma|tau|theta|Theta|xi|Xi|zeta"; // uuu nnn?
821
- var letter = "[a-zA-HJ-Z](?=(?:[^a-zA-Z]|$|" + ambigAMtoken + englishAMtoken + simpleAMtoken + "))|";
822
- var token = letter + texcommand + "\\d+|[-()[\\]{}+=*&^_%\\\@/<>,\\|!:;'~]|\\.(?!(?:\x20|$))|" + ambigAMtoken + englishAMtoken + simpleAMtoken;
823
- var re = new RegExp("(^|\\s)(((" + token + ")\\s?)((" + token + secondenglishAMtoken + ")\\s?)+)([,.?]?(?=\\s|$))", "g");
813
+ let texcommand = "\\\\[a-zA-Z]+|\\\\\\s|";
814
+ let ambigAMtoken = "\\b(?:oo|lim|ln|int|oint|del|grad|aleph|prod|prop|sinh|cosh|tanh|cos|sec|pi|tt|fr|sf|sube|supe|sub|sup|det|mod|gcd|lcm|min|max|vec|ddot|ul|chi|eta|nu|mu)(?![a-z])|";
815
+ let englishAMtoken = "\\b(?:sum|ox|log|sin|tan|dim|hat|bar|dot)(?![a-z])|";
816
+ let secondenglishAMtoken = "|\\bI\\b|\\bin\\b|\\btext\\b"; // took if and or not out
817
+ let simpleAMtoken = "NN|ZZ|QQ|RR|CC|TT|AA|EE|sqrt|dx|dy|dz|dt|xx|vv|uu|nn|bb|cc|csc|cot|alpha|beta|delta|Delta|epsilon|gamma|Gamma|kappa|lambda|Lambda|omega|phi|Phi|Pi|psi|Psi|rho|sigma|Sigma|tau|theta|Theta|xi|Xi|zeta"; // uuu nnn?
818
+ let letter = "[a-zA-HJ-Z](?=(?:[^a-zA-Z]|$|" + ambigAMtoken + englishAMtoken + simpleAMtoken + "))|";
819
+ let token = letter + texcommand + "\\d+|[-()[\\]{}+=*&^_%\\\@/<>,\\|!:;'~]|\\.(?!(?:\x20|$))|" + ambigAMtoken + englishAMtoken + simpleAMtoken;
820
+ let re = new RegExp("(^|\\s)(((" + token + ")\\s?)((" + token + secondenglishAMtoken + ")\\s?)+)([,.?]?(?=\\s|$))", "g");
824
821
  str = str.replace(re, " `$2`$7");
825
- var arr = str.split(this.AMdelimiter1);
826
- var re1 = new RegExp("(^|\\s)([b-zB-HJ-Z+*<>]|" + texcommand + ambigAMtoken + simpleAMtoken + ")(\\s|\\n|$)", "g");
827
- var re2 = new RegExp("(^|\\s)([a-z]|" + texcommand + ambigAMtoken + simpleAMtoken + ")([,.])", "g"); // removed |\d+ for now
828
- var i;
822
+ let arr = str.split(this.AMdelimiter1);
823
+ let re1 = new RegExp("(^|\\s)([b-zB-HJ-Z+*<>]|" + texcommand + ambigAMtoken + simpleAMtoken + ")(\\s|\\n|$)", "g");
824
+ let re2 = new RegExp("(^|\\s)([a-z]|" + texcommand + ambigAMtoken + simpleAMtoken + ")([,.])", "g"); // removed |\d+ for now
825
+ let i;
829
826
  for (i = 0; i < arr.length; i++) //single nonenglish tokens
830
827
  if (i % 2 == 0) {
831
828
  arr[i] = arr[i].replace(re1, " `$2`$3");
@@ -840,9 +837,9 @@ var AsciiMath = /** @class */ (function () {
840
837
  str = str.replace(/`([0-9.]+|e.g|i.e)`(\.?)/gi, "$1$2");
841
838
  str = str.replace(/`([0-9.]+:)`/g, "$1");
842
839
  return str;
843
- };
844
- AsciiMath.prototype.processNodeR = function (n, linebreaks) {
845
- var mtch, str, arr, frg, i;
840
+ }
841
+ processNodeR(n, linebreaks) {
842
+ let mtch, str, arr, frg, i;
846
843
  if (n.childNodes.length == 0) {
847
844
  if ((n.nodeType != 8 || linebreaks) &&
848
845
  n.parentNode.nodeName != "form" && n.parentNode.nodeName != "FORM" &&
@@ -880,7 +877,7 @@ var AsciiMath = /** @class */ (function () {
880
877
  if (arr.length > 1 || mtch) {
881
878
  if (!this.noMathML) {
882
879
  frg = this.strarr2docFrag(arr, n.nodeType == 8);
883
- var len = frg.childNodes.length;
880
+ let len = frg.childNodes.length;
884
881
  n.parentNode.replaceChild(frg, n);
885
882
  return len - 1;
886
883
  }
@@ -897,20 +894,20 @@ var AsciiMath = /** @class */ (function () {
897
894
  i += this.processNodeR(n.childNodes[i], linebreaks);
898
895
  }
899
896
  return 0;
900
- };
897
+ }
901
898
  /** hunt through a document and translate every math element.
902
899
  * if spanclassAM is provided, then it is the <tag> that holds math (perhaps 'span'?)
903
900
  * otherwise we go looking for AMdelimiter
904
901
  */
905
- AsciiMath.prototype.AMprocessNode = function (n, linebreaks, spanclassAM) {
902
+ AMprocessNode(n, linebreaks, spanclassAM) {
906
903
  if (spanclassAM != null) {
907
- var frag = document.getElementsByTagName(spanclassAM);
908
- for (var i = 0; i < frag.length; i++)
904
+ let frag = document.getElementsByTagName(spanclassAM);
905
+ for (let i = 0; i < frag.length; i++)
909
906
  if (frag[i].className == "AM")
910
907
  this.processNodeR(frag[i], linebreaks);
911
908
  }
912
909
  else {
913
- var st = void 0;
910
+ let st;
914
911
  try {
915
912
  st = n.innerHTML; // look for AMdelimiter on page
916
913
  }
@@ -922,9 +919,9 @@ var AsciiMath = /** @class */ (function () {
922
919
  this.processNodeR(n, linebreaks);
923
920
  }
924
921
  }
925
- };
922
+ }
926
923
  /** load the parsing table. Needs to be reloaded when fixPHI is changed. */
927
- AsciiMath.prototype.loadAMSymbols = function () {
924
+ loadAMSymbols() {
928
925
  this.AMSymbols = [
929
926
  //some greek symbols
930
927
  { input: "alpha", tag: "mi", output: "\u03B1", tex: null, ttype: CONST },
@@ -982,7 +979,7 @@ var AsciiMath = /** @class */ (function () {
982
979
  { input: "@", tag: "mo", output: "\u2218", tex: "circ", ttype: CONST },
983
980
  { input: "o+", tag: "mo", output: "\u2295", tex: "oplus", ttype: CONST },
984
981
  { input: "ox", tag: "mo", output: "\u2297", tex: "otimes", ttype: CONST },
985
- { input: "o.", tag: "mo", output: "\u2299", /*amparsei*/ tex: "odot", ttype: CONST },
982
+ { input: "o.", tag: "mo", output: "\u2299", /*amparsei*/ tex: "odot", ttype: CONST }, //tbtb
986
983
  { input: "sum", tag: "mo", output: "\u2211", tex: null, ttype: UNDEROVER },
987
984
  { input: "prod", tag: "mo", output: "\u220F", tex: null, ttype: UNDEROVER },
988
985
  { input: "^^", tag: "mo", output: "\u2227", tex: "wedge", ttype: CONST },
@@ -1195,7 +1192,5 @@ var AsciiMath = /** @class */ (function () {
1195
1192
  { input: "fr", tag: "mstyle", atname: "mathvariant", atval: "fraktur", output: "fr", tex: null, ttype: UNARY, codes: AMfrk },
1196
1193
  { input: "mathfrak", tag: "mstyle", atname: "mathvariant", atval: "fraktur", output: "mathfrak", tex: null, ttype: UNARY, codes: AMfrk }
1197
1194
  ];
1198
- };
1199
- return AsciiMath;
1200
- }());
1201
- exports.AsciiMath = AsciiMath;
1195
+ }
1196
+ }
@@ -3,8 +3,8 @@
3
3
  ASCIIMathML.ts
4
4
  ==============
5
5
  lightly modified by Tom Berend - original copyright below...
6
- convert to a TS function that accepts AsciiMath and returns MathML.
7
- not a page translator. Don't touch my document, I'll do that.
6
+ convert to a TS function that accepts AsciiMath and returns MathML.
7
+ not a page translator. Don't touch my document, I'll do that.
8
8
  and don't worry about IE.
9
9
  got rid of the onLoad function (just use ASCIIMathML.js for that)
10
10
 
@@ -75,12 +75,12 @@ type AMSymbol = {
75
75
  invisible?: boolean // all these other unreliable elements ?!?!
76
76
  func?: boolean
77
77
  acc?: boolean
78
- rewriteleftright?: string[] // always two
78
+ rewriteleftright?: string[] // always two
79
79
  notexcopy?: boolean
80
80
 
81
81
  atname?: "mathvariant",
82
82
  atval?: "bold" | "sans-serif" | "double-struck" | "script" | "fraktur" | "monospace"
83
- codes?: string[] // AMcal | AMfrk | AMbbb |
83
+ codes?: string[] // AMcal | AMfrk | AMbbb |
84
84
  }
85
85
 
86
86
  type Tag = 'div' | 'p' | 'span' | 'body' | 'a'
@@ -920,7 +920,7 @@ export class AsciiMath {
920
920
  return 0;
921
921
  }
922
922
 
923
- /** hunt through a document and translate every math element.
923
+ /** hunt through a document and translate every math element.
924
924
  * if spanclassAM is provided, then it is the <tag> that holds math (perhaps 'span'?)
925
925
  * otherwise we go looking for AMdelimiter
926
926
  */
package/index.html ADDED
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <title>AsciiMath Example</title>
7
+ </script>
8
+ </head>
9
+
10
+ <body>
11
+
12
+ <div id="buttons"></div>
13
+
14
+ <p id="insertMathHere"></p>
15
+
16
+ <script type="module">
17
+ import { AsciiMath } from "./asciimath.js"
18
+
19
+ let a = new AsciiMath()
20
+ let eqn = 'sum_(i=1)^n i^3=((n(n+1))/2)^2'
21
+ document.getElementById('insertMathHere').appendChild(a.parseMath(eqn))
22
+
23
+ </script>
24
+
25
+ </body>
26
+
27
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asciimathml-ts",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "AsciiMathML converted to TS",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -15,5 +15,13 @@
15
15
  "author": "",
16
16
  "license": "ISC",
17
17
  "homepage": "https://github.com/tom-berend/asciimathml#readme",
18
- "keywords": ["MathML","ASCIIMath","ASCIIMathML","TypeScript"]
18
+ "keywords": [
19
+ "MathML",
20
+ "ASCIIMath",
21
+ "ASCIIMathML",
22
+ "TypeScript"
23
+ ],
24
+ "dependencies": {
25
+ "typescript": "^5.9.3"
26
+ }
19
27
  }
package/tsconfig.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "declaration": true,
4
- "target": "es5",
5
- "module": "commonjs",
4
+ "target": "es6",
5
+ "module": "es6",
6
6
  "strict": false,
7
7
  "esModuleInterop": true,
8
8
  "skipLibCheck": true