temml 0.11.11 → 0.12.1
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 +1 -1
- package/dist/temml.cjs +208 -230
- package/dist/temml.d.ts +2 -2
- package/dist/temml.js +208 -230
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +208 -230
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +1 -1
- package/src/Settings.js +3 -3
- package/src/buildMathML.js +1 -1
- package/src/domTree.js +1 -1
- package/src/environments/array.js +2 -3
- package/src/environments/cd.js +1 -1
- package/src/functions/accent.js +2 -2
- package/src/functions/accentunder.js +2 -2
- package/src/functions/arrow.js +2 -2
- package/src/functions/cancelto.js +1 -1
- package/src/functions/color.js +1 -1
- package/src/functions/cr.js +1 -1
- package/src/functions/delimsizing.js +1 -1
- package/src/functions/enclose.js +3 -3
- package/src/functions/envTag.js +1 -1
- package/src/functions/font.js +1 -1
- package/src/functions/genfrac.js +1 -1
- package/src/functions/horizBrace.js +2 -2
- package/src/functions/includegraphics.js +1 -1
- package/src/functions/kern.js +1 -1
- package/src/functions/label.js +1 -1
- package/src/functions/lap.js +1 -1
- package/src/functions/mclass.js +2 -2
- package/src/functions/multiscript.js +1 -1
- package/src/functions/not.js +1 -1
- package/src/functions/operatorname.js +1 -1
- package/src/functions/phantom.js +1 -1
- package/src/functions/raise.js +1 -1
- package/src/functions/rule.js +1 -1
- package/src/functions/sfrac.js +1 -1
- package/src/functions/smash.js +1 -1
- package/src/functions/sqrt.js +1 -1
- package/src/functions/supsub.js +1 -1
- package/src/functions/symbolsOp.js +1 -1
- package/src/functions/symbolsOrd.js +1 -1
- package/src/functions/symbolsSpacing.js +1 -1
- package/src/functions/tip.js +1 -1
- package/src/functions/toggle.js +1 -1
- package/src/functions/vcenter.js +1 -1
- package/src/functions/verb.js +1 -1
- package/src/linebreaking.js +1 -1
- package/src/mathMLTree.js +1 -7
- package/src/postProcess.js +1 -1
- package/src/stretchy.js +3 -8
- package/src/units.js +1 -1
- package/src/utils.js +6 -16
package/dist/temml.js
CHANGED
|
@@ -182,16 +182,6 @@ var temml = (function () {
|
|
|
182
182
|
return +n.toFixed(4);
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
var utils = {
|
|
186
|
-
deflt,
|
|
187
|
-
escape,
|
|
188
|
-
hyphenate,
|
|
189
|
-
getBaseElem,
|
|
190
|
-
isCharacterBox,
|
|
191
|
-
protocolFromUrl,
|
|
192
|
-
round
|
|
193
|
-
};
|
|
194
|
-
|
|
195
185
|
/**
|
|
196
186
|
* This is a module for storing settings passed into Temml. It correctly handles
|
|
197
187
|
* default settings.
|
|
@@ -205,24 +195,24 @@ var temml = (function () {
|
|
|
205
195
|
constructor(options) {
|
|
206
196
|
// allow null options
|
|
207
197
|
options = options || {};
|
|
208
|
-
this.displayMode =
|
|
209
|
-
this.annotate =
|
|
210
|
-
this.leqno =
|
|
211
|
-
this.throwOnError =
|
|
212
|
-
this.errorColor =
|
|
198
|
+
this.displayMode = deflt(options.displayMode, false); // boolean
|
|
199
|
+
this.annotate = deflt(options.annotate, false); // boolean
|
|
200
|
+
this.leqno = deflt(options.leqno, false); // boolean
|
|
201
|
+
this.throwOnError = deflt(options.throwOnError, false); // boolean
|
|
202
|
+
this.errorColor = deflt(options.errorColor, "#b22222"); // string
|
|
213
203
|
this.macros = options.macros || {};
|
|
214
|
-
this.wrap =
|
|
215
|
-
this.xml =
|
|
216
|
-
this.colorIsTextColor =
|
|
217
|
-
this.strict =
|
|
218
|
-
this.trust =
|
|
204
|
+
this.wrap = deflt(options.wrap, "none"); // "none" | "tex" | "="
|
|
205
|
+
this.xml = deflt(options.xml, false); // boolean
|
|
206
|
+
this.colorIsTextColor = deflt(options.colorIsTextColor, false); // boolean
|
|
207
|
+
this.strict = deflt(options.strict, false); // boolean
|
|
208
|
+
this.trust = deflt(options.trust, false); // trust context. See html.js.
|
|
219
209
|
this.maxSize = (options.maxSize === undefined
|
|
220
210
|
? [Infinity, Infinity]
|
|
221
211
|
: Array.isArray(options.maxSize)
|
|
222
212
|
? options.maxSize
|
|
223
213
|
: [Infinity, Infinity]
|
|
224
214
|
);
|
|
225
|
-
this.maxExpand = Math.max(0,
|
|
215
|
+
this.maxExpand = Math.max(0, deflt(options.maxExpand, 1000)); // number
|
|
226
216
|
}
|
|
227
217
|
|
|
228
218
|
/**
|
|
@@ -235,7 +225,7 @@ var temml = (function () {
|
|
|
235
225
|
*/
|
|
236
226
|
isTrusted(context) {
|
|
237
227
|
if (context.url && !context.protocol) {
|
|
238
|
-
const protocol =
|
|
228
|
+
const protocol = protocolFromUrl(context.url);
|
|
239
229
|
if (protocol == null) {
|
|
240
230
|
return false
|
|
241
231
|
}
|
|
@@ -431,7 +421,7 @@ var temml = (function () {
|
|
|
431
421
|
|
|
432
422
|
// Add the class
|
|
433
423
|
if (this.classes.length) {
|
|
434
|
-
markup += ` class="${
|
|
424
|
+
markup += ` class="${escape(createClass(this.classes))}"`;
|
|
435
425
|
}
|
|
436
426
|
|
|
437
427
|
let styles = "";
|
|
@@ -439,7 +429,7 @@ var temml = (function () {
|
|
|
439
429
|
// Add the styles, after hyphenation
|
|
440
430
|
for (const style in this.style) {
|
|
441
431
|
if (Object.prototype.hasOwnProperty.call(this.style, style )) {
|
|
442
|
-
styles += `${
|
|
432
|
+
styles += `${hyphenate(style)}:${this.style[style]};`;
|
|
443
433
|
}
|
|
444
434
|
}
|
|
445
435
|
|
|
@@ -450,7 +440,7 @@ var temml = (function () {
|
|
|
450
440
|
// Add the attributes
|
|
451
441
|
for (const attr in this.attributes) {
|
|
452
442
|
if (Object.prototype.hasOwnProperty.call(this.attributes, attr )) {
|
|
453
|
-
markup += ` ${attr}="${
|
|
443
|
+
markup += ` ${attr}="${escape(this.attributes[attr])}"`;
|
|
454
444
|
}
|
|
455
445
|
}
|
|
456
446
|
|
|
@@ -498,7 +488,7 @@ var temml = (function () {
|
|
|
498
488
|
return document.createTextNode(this.text);
|
|
499
489
|
}
|
|
500
490
|
toMarkup() {
|
|
501
|
-
return
|
|
491
|
+
return escape(this.text);
|
|
502
492
|
}
|
|
503
493
|
};
|
|
504
494
|
|
|
@@ -523,9 +513,9 @@ var temml = (function () {
|
|
|
523
513
|
}
|
|
524
514
|
|
|
525
515
|
toMarkup() {
|
|
526
|
-
let markup = `<a href='${
|
|
516
|
+
let markup = `<a href='${escape(this.href)}'`;
|
|
527
517
|
if (this.classes.length > 0) {
|
|
528
|
-
markup += ` class="${
|
|
518
|
+
markup += ` class="${escape(createClass(this.classes))}"`;
|
|
529
519
|
}
|
|
530
520
|
markup += ">";
|
|
531
521
|
for (let i = 0; i < this.children.length; i++) {
|
|
@@ -574,11 +564,11 @@ var temml = (function () {
|
|
|
574
564
|
let styles = "";
|
|
575
565
|
for (const style in this.style) {
|
|
576
566
|
if (Object.prototype.hasOwnProperty.call(this.style, style )) {
|
|
577
|
-
styles += `${
|
|
567
|
+
styles += `${hyphenate(style)}:${this.style[style]};`;
|
|
578
568
|
}
|
|
579
569
|
}
|
|
580
570
|
if (styles) {
|
|
581
|
-
markup += ` style="${
|
|
571
|
+
markup += ` style="${escape(styles)}"`;
|
|
582
572
|
}
|
|
583
573
|
|
|
584
574
|
markup += ">";
|
|
@@ -672,13 +662,13 @@ var temml = (function () {
|
|
|
672
662
|
for (const attr in this.attributes) {
|
|
673
663
|
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
674
664
|
markup += " " + attr + '="';
|
|
675
|
-
markup +=
|
|
665
|
+
markup += escape(this.attributes[attr]);
|
|
676
666
|
markup += '"';
|
|
677
667
|
}
|
|
678
668
|
}
|
|
679
669
|
|
|
680
670
|
if (this.classes.length > 0) {
|
|
681
|
-
markup += ` class="${
|
|
671
|
+
markup += ` class="${escape(createClass(this.classes))}"`;
|
|
682
672
|
}
|
|
683
673
|
|
|
684
674
|
let styles = "";
|
|
@@ -686,7 +676,7 @@ var temml = (function () {
|
|
|
686
676
|
// Add the styles, after hyphenation
|
|
687
677
|
for (const style in this.style) {
|
|
688
678
|
if (Object.prototype.hasOwnProperty.call(this.style, style )) {
|
|
689
|
-
styles += `${
|
|
679
|
+
styles += `${hyphenate(style)}:${this.style[style]};`;
|
|
690
680
|
}
|
|
691
681
|
}
|
|
692
682
|
|
|
@@ -733,7 +723,7 @@ var temml = (function () {
|
|
|
733
723
|
* (representing the text itself).
|
|
734
724
|
*/
|
|
735
725
|
toMarkup() {
|
|
736
|
-
return
|
|
726
|
+
return escape(this.toText());
|
|
737
727
|
}
|
|
738
728
|
|
|
739
729
|
/**
|
|
@@ -758,12 +748,6 @@ var temml = (function () {
|
|
|
758
748
|
return node
|
|
759
749
|
};
|
|
760
750
|
|
|
761
|
-
var mathMLTree = {
|
|
762
|
-
MathNode,
|
|
763
|
-
TextNode,
|
|
764
|
-
newDocumentFragment
|
|
765
|
-
};
|
|
766
|
-
|
|
767
751
|
/**
|
|
768
752
|
* This file provides support for building horizontal stretchy elements.
|
|
769
753
|
*/
|
|
@@ -855,8 +839,8 @@ var temml = (function () {
|
|
|
855
839
|
};
|
|
856
840
|
|
|
857
841
|
const mathMLnode = function(label) {
|
|
858
|
-
const child = new
|
|
859
|
-
const node = new
|
|
842
|
+
const child = new TextNode(stretchyCodePoint[label.slice(1)]);
|
|
843
|
+
const node = new MathNode("mo", [child]);
|
|
860
844
|
node.setAttribute("stretchy", "true");
|
|
861
845
|
return node
|
|
862
846
|
};
|
|
@@ -879,11 +863,6 @@ var temml = (function () {
|
|
|
879
863
|
return mo
|
|
880
864
|
};
|
|
881
865
|
|
|
882
|
-
var stretchy = {
|
|
883
|
-
mathMLnode,
|
|
884
|
-
accentNode
|
|
885
|
-
};
|
|
886
|
-
|
|
887
866
|
/**
|
|
888
867
|
* This file holds a list of all no-argument functions and single-character
|
|
889
868
|
* symbols (like 'a' or ';').
|
|
@@ -2037,13 +2016,13 @@ var temml = (function () {
|
|
|
2037
2016
|
node.attributes.linebreak === "newline") {
|
|
2038
2017
|
// A hard line break. Create a <mtr> for the current block.
|
|
2039
2018
|
if (block.length > 0) {
|
|
2040
|
-
mrows.push(new
|
|
2019
|
+
mrows.push(new MathNode("mrow", block));
|
|
2041
2020
|
}
|
|
2042
2021
|
mrows.push(node);
|
|
2043
2022
|
block = [];
|
|
2044
|
-
const mtd = new
|
|
2023
|
+
const mtd = new MathNode("mtd", mrows);
|
|
2045
2024
|
mtd.style.textAlign = "left";
|
|
2046
|
-
mtrs.push(new
|
|
2025
|
+
mtrs.push(new MathNode("mtr", [mtd]));
|
|
2047
2026
|
mrows = [];
|
|
2048
2027
|
i += 1;
|
|
2049
2028
|
continue
|
|
@@ -2061,7 +2040,7 @@ var temml = (function () {
|
|
|
2061
2040
|
if (numTopLevelEquals > 1) {
|
|
2062
2041
|
block.pop();
|
|
2063
2042
|
// Start a new block. (Insert a soft linebreak.)
|
|
2064
|
-
const element = new
|
|
2043
|
+
const element = new MathNode("mrow", block);
|
|
2065
2044
|
mrows.push(element);
|
|
2066
2045
|
block = [node];
|
|
2067
2046
|
}
|
|
@@ -2102,7 +2081,7 @@ var temml = (function () {
|
|
|
2102
2081
|
}
|
|
2103
2082
|
if (glueIsFreeOfNobreak) {
|
|
2104
2083
|
// Start a new block. (Insert a soft linebreak.)
|
|
2105
|
-
const element = new
|
|
2084
|
+
const element = new MathNode("mrow", block);
|
|
2106
2085
|
mrows.push(element);
|
|
2107
2086
|
block = [];
|
|
2108
2087
|
}
|
|
@@ -2111,22 +2090,22 @@ var temml = (function () {
|
|
|
2111
2090
|
i += 1;
|
|
2112
2091
|
}
|
|
2113
2092
|
if (block.length > 0) {
|
|
2114
|
-
const element = new
|
|
2093
|
+
const element = new MathNode("mrow", block);
|
|
2115
2094
|
mrows.push(element);
|
|
2116
2095
|
}
|
|
2117
2096
|
if (mtrs.length > 0) {
|
|
2118
|
-
const mtd = new
|
|
2097
|
+
const mtd = new MathNode("mtd", mrows);
|
|
2119
2098
|
mtd.style.textAlign = "left";
|
|
2120
|
-
const mtr = new
|
|
2099
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
2121
2100
|
mtrs.push(mtr);
|
|
2122
|
-
const mtable = new
|
|
2101
|
+
const mtable = new MathNode("mtable", mtrs);
|
|
2123
2102
|
if (!isDisplayMode) {
|
|
2124
2103
|
mtable.setAttribute("columnalign", "left");
|
|
2125
2104
|
mtable.setAttribute("rowspacing", "0em");
|
|
2126
2105
|
}
|
|
2127
2106
|
return mtable
|
|
2128
2107
|
}
|
|
2129
|
-
return
|
|
2108
|
+
return newDocumentFragment(mrows);
|
|
2130
2109
|
}
|
|
2131
2110
|
|
|
2132
2111
|
/**
|
|
@@ -2155,15 +2134,15 @@ var temml = (function () {
|
|
|
2155
2134
|
text = symbols[mode][text].replace;
|
|
2156
2135
|
}
|
|
2157
2136
|
|
|
2158
|
-
return new
|
|
2137
|
+
return new TextNode(text);
|
|
2159
2138
|
};
|
|
2160
2139
|
|
|
2161
2140
|
const copyChar = (newRow, child) => {
|
|
2162
2141
|
if (newRow.children.length === 0 ||
|
|
2163
2142
|
newRow.children[newRow.children.length - 1].type !== "mtext") {
|
|
2164
|
-
const mtext = new
|
|
2143
|
+
const mtext = new MathNode(
|
|
2165
2144
|
"mtext",
|
|
2166
|
-
[new
|
|
2145
|
+
[new TextNode(child.children[0].text)]
|
|
2167
2146
|
);
|
|
2168
2147
|
newRow.children.push(mtext);
|
|
2169
2148
|
} else {
|
|
@@ -2175,7 +2154,7 @@ var temml = (function () {
|
|
|
2175
2154
|
// If possible, consolidate adjacent <mtext> elements into a single element.
|
|
2176
2155
|
if (mrow.type !== "mrow" && mrow.type !== "mstyle") { return mrow }
|
|
2177
2156
|
if (mrow.children.length === 0) { return mrow } // empty group, e.g., \text{}
|
|
2178
|
-
const newRow = new
|
|
2157
|
+
const newRow = new MathNode("mrow");
|
|
2179
2158
|
for (let i = 0; i < mrow.children.length; i++) {
|
|
2180
2159
|
const child = mrow.children[i];
|
|
2181
2160
|
if (child.type === "mtext" && Object.keys(child.attributes).length === 0) {
|
|
@@ -2245,7 +2224,7 @@ var temml = (function () {
|
|
|
2245
2224
|
body[end].attributes.rspace = "0em";
|
|
2246
2225
|
}
|
|
2247
2226
|
}
|
|
2248
|
-
return new
|
|
2227
|
+
return new MathNode("mrow", body);
|
|
2249
2228
|
};
|
|
2250
2229
|
|
|
2251
2230
|
/**
|
|
@@ -2370,7 +2349,7 @@ var temml = (function () {
|
|
|
2370
2349
|
*/
|
|
2371
2350
|
const buildGroup$1 = function(group, style) {
|
|
2372
2351
|
if (!group) {
|
|
2373
|
-
return new
|
|
2352
|
+
return new MathNode("mrow");
|
|
2374
2353
|
}
|
|
2375
2354
|
|
|
2376
2355
|
if (_mathmlGroupBuilders[group.type]) {
|
|
@@ -2383,7 +2362,7 @@ var temml = (function () {
|
|
|
2383
2362
|
};
|
|
2384
2363
|
|
|
2385
2364
|
const glue$1 = _ => {
|
|
2386
|
-
return new
|
|
2365
|
+
return new MathNode("mtd", [], [], { padding: "0", width: "50%" })
|
|
2387
2366
|
};
|
|
2388
2367
|
|
|
2389
2368
|
const labelContainers = ["mrow", "mtd", "mtable", "mtr"];
|
|
@@ -2410,12 +2389,12 @@ var temml = (function () {
|
|
|
2410
2389
|
tag.classes.push("tml-tag"); // to be available for \ref
|
|
2411
2390
|
|
|
2412
2391
|
const label = getLabel(expression); // from a \label{} function.
|
|
2413
|
-
expression = new
|
|
2392
|
+
expression = new MathNode("mtd", [expression]);
|
|
2414
2393
|
const rowArray = [glue$1(), expression, glue$1()];
|
|
2415
2394
|
rowArray[leqno ? 0 : 2].children.push(tag);
|
|
2416
|
-
const mtr = new
|
|
2395
|
+
const mtr = new MathNode("mtr", rowArray, ["tml-tageqn"]);
|
|
2417
2396
|
if (label) { mtr.setAttribute("id", label); }
|
|
2418
|
-
const table = new
|
|
2397
|
+
const table = new MathNode("mtable", [mtr]);
|
|
2419
2398
|
table.style.width = "100%";
|
|
2420
2399
|
table.setAttribute("displaystyle", "true");
|
|
2421
2400
|
return table
|
|
@@ -2452,13 +2431,13 @@ var temml = (function () {
|
|
|
2452
2431
|
|
|
2453
2432
|
if (settings.annotate) {
|
|
2454
2433
|
// Build a TeX annotation of the source
|
|
2455
|
-
const annotation = new
|
|
2456
|
-
"annotation", [new
|
|
2434
|
+
const annotation = new MathNode(
|
|
2435
|
+
"annotation", [new TextNode(texExpression)]);
|
|
2457
2436
|
annotation.setAttribute("encoding", "application/x-tex");
|
|
2458
|
-
wrapper = new
|
|
2437
|
+
wrapper = new MathNode("semantics", [wrapper, annotation]);
|
|
2459
2438
|
}
|
|
2460
2439
|
|
|
2461
|
-
const math = new
|
|
2440
|
+
const math = new MathNode("math", [wrapper]);
|
|
2462
2441
|
|
|
2463
2442
|
if (settings.xml) {
|
|
2464
2443
|
math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
|
|
@@ -2482,14 +2461,14 @@ var temml = (function () {
|
|
|
2482
2461
|
const largeNudge = "AFJdfΔΛ";
|
|
2483
2462
|
|
|
2484
2463
|
const mathmlBuilder$a = (group, style) => {
|
|
2485
|
-
const accentNode = group.isStretchy
|
|
2486
|
-
?
|
|
2487
|
-
: new
|
|
2464
|
+
const accentNode$1 = group.isStretchy
|
|
2465
|
+
? accentNode(group)
|
|
2466
|
+
: new MathNode("mo", [makeText(group.label, group.mode)]);
|
|
2488
2467
|
if (!group.isStretchy) {
|
|
2489
|
-
accentNode.setAttribute("stretchy", "false"); // Keep Firefox from stretching \check
|
|
2468
|
+
accentNode$1.setAttribute("stretchy", "false"); // Keep Firefox from stretching \check
|
|
2490
2469
|
}
|
|
2491
2470
|
if (group.label !== "\\vec") {
|
|
2492
|
-
accentNode.style.mathDepth = "0"; // not scriptstyle
|
|
2471
|
+
accentNode$1.style.mathDepth = "0"; // not scriptstyle
|
|
2493
2472
|
// Don't use attribute accent="true" because MathML Core eliminates a needed space.
|
|
2494
2473
|
}
|
|
2495
2474
|
const tag = group.label === "\\c" ? "munder" : "mover";
|
|
@@ -2500,28 +2479,28 @@ var temml = (function () {
|
|
|
2500
2479
|
const isVec = group.label === "\\vec";
|
|
2501
2480
|
const vecPostfix = isVec === "\\vec" ? "-vec" : "";
|
|
2502
2481
|
if (isVec) {
|
|
2503
|
-
accentNode.classes.push("tml-vec"); // Firefox sizing of \vec arrow
|
|
2482
|
+
accentNode$1.classes.push("tml-vec"); // Firefox sizing of \vec arrow
|
|
2504
2483
|
}
|
|
2505
2484
|
const wbkPostfix = isVec ? "-vec" : needsWbkVertShift ? "-acc" : "";
|
|
2506
2485
|
if (smallNudge.indexOf(text) > -1) {
|
|
2507
|
-
accentNode.classes.push(`chr-sml${vecPostfix}`);
|
|
2508
|
-
accentNode.classes.push(`wbk-sml${wbkPostfix}`);
|
|
2486
|
+
accentNode$1.classes.push(`chr-sml${vecPostfix}`);
|
|
2487
|
+
accentNode$1.classes.push(`wbk-sml${wbkPostfix}`);
|
|
2509
2488
|
} else if (mediumNudge.indexOf(text) > -1) {
|
|
2510
|
-
accentNode.classes.push(`chr-med${vecPostfix}`);
|
|
2511
|
-
accentNode.classes.push(`wbk-med${wbkPostfix}`);
|
|
2489
|
+
accentNode$1.classes.push(`chr-med${vecPostfix}`);
|
|
2490
|
+
accentNode$1.classes.push(`wbk-med${wbkPostfix}`);
|
|
2512
2491
|
} else if (largeNudge.indexOf(text) > -1) {
|
|
2513
|
-
accentNode.classes.push(`chr-lrg${vecPostfix}`);
|
|
2514
|
-
accentNode.classes.push(`wbk-lrg${wbkPostfix}`);
|
|
2492
|
+
accentNode$1.classes.push(`chr-lrg${vecPostfix}`);
|
|
2493
|
+
accentNode$1.classes.push(`wbk-lrg${wbkPostfix}`);
|
|
2515
2494
|
} else if (isVec) {
|
|
2516
|
-
accentNode.classes.push(`wbk-vec`);
|
|
2495
|
+
accentNode$1.classes.push(`wbk-vec`);
|
|
2517
2496
|
} else if (needsWbkVertShift) {
|
|
2518
|
-
accentNode.classes.push(`wbk-acc`);
|
|
2497
|
+
accentNode$1.classes.push(`wbk-acc`);
|
|
2519
2498
|
}
|
|
2520
2499
|
} else if (needsWbkVertShift) {
|
|
2521
2500
|
// text-mode accents
|
|
2522
|
-
accentNode.classes.push("wbk-acc");
|
|
2501
|
+
accentNode$1.classes.push("wbk-acc");
|
|
2523
2502
|
}
|
|
2524
|
-
const node = new
|
|
2503
|
+
const node = new MathNode(tag, [buildGroup$1(group.base, style), accentNode$1]);
|
|
2525
2504
|
return node;
|
|
2526
2505
|
};
|
|
2527
2506
|
|
|
@@ -2688,11 +2667,11 @@ var temml = (function () {
|
|
|
2688
2667
|
};
|
|
2689
2668
|
},
|
|
2690
2669
|
mathmlBuilder: (group, style) => {
|
|
2691
|
-
const accentNode =
|
|
2692
|
-
accentNode.style["math-depth"] = 0;
|
|
2693
|
-
const node = new
|
|
2670
|
+
const accentNode$1 = accentNode(group);
|
|
2671
|
+
accentNode$1.style["math-depth"] = 0;
|
|
2672
|
+
const node = new MathNode("munder", [
|
|
2694
2673
|
buildGroup$1(group.base, style),
|
|
2695
|
-
accentNode
|
|
2674
|
+
accentNode$1
|
|
2696
2675
|
]);
|
|
2697
2676
|
return node;
|
|
2698
2677
|
}
|
|
@@ -2781,7 +2760,7 @@ var temml = (function () {
|
|
|
2781
2760
|
// In TeX, em and ex do not change size in \scriptstyle.
|
|
2782
2761
|
if (unit === "ex") { number *= 0.431; }
|
|
2783
2762
|
number = Math.min(number / emScale(style.level), style.maxSize[0]);
|
|
2784
|
-
return { number:
|
|
2763
|
+
return { number: round(number), unit: "em" };
|
|
2785
2764
|
}
|
|
2786
2765
|
case "bp": {
|
|
2787
2766
|
if (number > style.maxSize[1]) { number = style.maxSize[1]; }
|
|
@@ -2795,11 +2774,11 @@ var temml = (function () {
|
|
|
2795
2774
|
case "nc":
|
|
2796
2775
|
case "sp": {
|
|
2797
2776
|
number = Math.min(number * ptPerUnit[unit], style.maxSize[1]);
|
|
2798
|
-
return { number:
|
|
2777
|
+
return { number: round(number), unit: "pt" }
|
|
2799
2778
|
}
|
|
2800
2779
|
case "mu": {
|
|
2801
2780
|
number = Math.min(number / 18, style.maxSize[0]);
|
|
2802
|
-
return { number:
|
|
2781
|
+
return { number: round(number), unit: "em" }
|
|
2803
2782
|
}
|
|
2804
2783
|
default:
|
|
2805
2784
|
throw new ParseError("Invalid unit: '" + unit + "'")
|
|
@@ -2809,7 +2788,7 @@ var temml = (function () {
|
|
|
2809
2788
|
// Helper functions
|
|
2810
2789
|
|
|
2811
2790
|
const padding = width => {
|
|
2812
|
-
const node = new
|
|
2791
|
+
const node = new MathNode("mspace");
|
|
2813
2792
|
node.setAttribute("width", width + "em");
|
|
2814
2793
|
return node
|
|
2815
2794
|
};
|
|
@@ -2821,18 +2800,18 @@ var temml = (function () {
|
|
|
2821
2800
|
if (rspace > 0) { row.push(padding(rspace)); }
|
|
2822
2801
|
if (mustSmash) {
|
|
2823
2802
|
// Used for the bottom arrow in a {CD} environment
|
|
2824
|
-
const mpadded = new
|
|
2803
|
+
const mpadded = new MathNode("mpadded", row);
|
|
2825
2804
|
mpadded.setAttribute("height", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
2826
2805
|
return mpadded
|
|
2827
2806
|
} else {
|
|
2828
|
-
return new
|
|
2807
|
+
return new MathNode("mrow", row)
|
|
2829
2808
|
}
|
|
2830
2809
|
};
|
|
2831
2810
|
|
|
2832
2811
|
const labelSize = (size, scriptLevel) => Number(size) / emScale(scriptLevel);
|
|
2833
2812
|
|
|
2834
2813
|
const munderoverNode = (fName, body, below, style) => {
|
|
2835
|
-
const arrowNode =
|
|
2814
|
+
const arrowNode = mathMLnode(fName);
|
|
2836
2815
|
// Is this the short part of a mhchem equilibrium arrow?
|
|
2837
2816
|
const isEq = fName.slice(1, 3) === "eq";
|
|
2838
2817
|
const minWidth = fName.charAt(1) === "x"
|
|
@@ -2871,25 +2850,25 @@ var temml = (function () {
|
|
|
2871
2850
|
// Since Firefox does not support minsize, stack a invisible node
|
|
2872
2851
|
// on top of the label. Its width will serve as a min-width.
|
|
2873
2852
|
// TODO: Refactor this after Firefox supports minsize.
|
|
2874
|
-
upperNode = new
|
|
2853
|
+
upperNode = new MathNode("mover", [label, dummyNode]);
|
|
2875
2854
|
}
|
|
2876
2855
|
const gotLower = (below && below.body &&
|
|
2877
2856
|
(below.body.body || below.body.length > 0));
|
|
2878
2857
|
if (gotLower) {
|
|
2879
2858
|
let label = buildGroup$1(below, labelStyle);
|
|
2880
2859
|
label = paddedNode(label, space, space);
|
|
2881
|
-
lowerNode = new
|
|
2860
|
+
lowerNode = new MathNode("munder", [label, dummyNode]);
|
|
2882
2861
|
}
|
|
2883
2862
|
|
|
2884
2863
|
let node;
|
|
2885
2864
|
if (!gotUpper && !gotLower) {
|
|
2886
|
-
node = new
|
|
2865
|
+
node = new MathNode("mover", [arrowNode, emptyLabel]);
|
|
2887
2866
|
} else if (gotUpper && gotLower) {
|
|
2888
|
-
node = new
|
|
2867
|
+
node = new MathNode("munderover", [arrowNode, lowerNode, upperNode]);
|
|
2889
2868
|
} else if (gotUpper) {
|
|
2890
|
-
node = new
|
|
2869
|
+
node = new MathNode("mover", [arrowNode, upperNode]);
|
|
2891
2870
|
} else {
|
|
2892
|
-
node = new
|
|
2871
|
+
node = new MathNode("munder", [arrowNode, lowerNode]);
|
|
2893
2872
|
}
|
|
2894
2873
|
if (minWidth === "3.0") { node.style.height = "1em"; } // CD environment
|
|
2895
2874
|
node.setAttribute("accent", "false"); // Necessary for MS Word
|
|
@@ -2952,7 +2931,7 @@ var temml = (function () {
|
|
|
2952
2931
|
const row = [node];
|
|
2953
2932
|
row.unshift(padding(0.2778));
|
|
2954
2933
|
row.push(padding(0.2778));
|
|
2955
|
-
return new
|
|
2934
|
+
return new MathNode("mrow", row)
|
|
2956
2935
|
}
|
|
2957
2936
|
});
|
|
2958
2937
|
|
|
@@ -3005,21 +2984,21 @@ var temml = (function () {
|
|
|
3005
2984
|
const botArrow = munderoverNode(botLabel, group.lowerArrowBody, group.below, style);
|
|
3006
2985
|
let wrapper;
|
|
3007
2986
|
|
|
3008
|
-
const raiseNode = new
|
|
2987
|
+
const raiseNode = new MathNode("mpadded", [topArrow]);
|
|
3009
2988
|
raiseNode.setAttribute("voffset", "0.3em");
|
|
3010
2989
|
raiseNode.setAttribute("height", "+0.3em");
|
|
3011
2990
|
raiseNode.setAttribute("depth", "-0.3em");
|
|
3012
2991
|
// One of the arrows is given ~zero width. so the other has the same horzontal alignment.
|
|
3013
2992
|
if (group.name === "\\equilibriumLeft") {
|
|
3014
|
-
const botNode = new
|
|
2993
|
+
const botNode = new MathNode("mpadded", [botArrow]);
|
|
3015
2994
|
botNode.setAttribute("width", "0.5em");
|
|
3016
|
-
wrapper = new
|
|
2995
|
+
wrapper = new MathNode(
|
|
3017
2996
|
"mpadded",
|
|
3018
2997
|
[padding(0.2778), botNode, raiseNode, padding(0.2778)]
|
|
3019
2998
|
);
|
|
3020
2999
|
} else {
|
|
3021
3000
|
raiseNode.setAttribute("width", (group.name === "\\equilibriumRight" ? "0.5em" : "0"));
|
|
3022
|
-
wrapper = new
|
|
3001
|
+
wrapper = new MathNode(
|
|
3023
3002
|
"mpadded",
|
|
3024
3003
|
[padding(0.2778), raiseNode, botArrow, padding(0.2778)]
|
|
3025
3004
|
);
|
|
@@ -3311,18 +3290,18 @@ var temml = (function () {
|
|
|
3311
3290
|
},
|
|
3312
3291
|
mathmlBuilder(group, style) {
|
|
3313
3292
|
if (group.label.body.length === 0) {
|
|
3314
|
-
return new
|
|
3293
|
+
return new MathNode("mrow", style) // empty label
|
|
3315
3294
|
}
|
|
3316
3295
|
// Abuse an <mtable> to create vertically centered content.
|
|
3317
3296
|
const mrow = buildGroup$1(group.label, style);
|
|
3318
3297
|
if (group.side === "left") {
|
|
3319
3298
|
mrow.classes.push("tml-shift-left");
|
|
3320
3299
|
}
|
|
3321
|
-
const mtd = new
|
|
3300
|
+
const mtd = new MathNode("mtd", [mrow]);
|
|
3322
3301
|
mtd.style.padding = "0";
|
|
3323
|
-
const mtr = new
|
|
3324
|
-
const mtable = new
|
|
3325
|
-
const label = new
|
|
3302
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
3303
|
+
const mtable = new MathNode("mtable", [mtr]);
|
|
3304
|
+
const label = new MathNode("mpadded", [mtable]);
|
|
3326
3305
|
// Set the label width to zero so that the arrow will be centered under the corner cell.
|
|
3327
3306
|
label.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
3328
3307
|
label.setAttribute("displaystyle", "false");
|
|
@@ -3345,7 +3324,7 @@ var temml = (function () {
|
|
|
3345
3324
|
};
|
|
3346
3325
|
},
|
|
3347
3326
|
mathmlBuilder(group, style) {
|
|
3348
|
-
return new
|
|
3327
|
+
return new MathNode("mrow", [buildGroup$1(group.fragment, style)]);
|
|
3349
3328
|
}
|
|
3350
3329
|
});
|
|
3351
3330
|
|
|
@@ -4530,7 +4509,7 @@ var temml = (function () {
|
|
|
4530
4509
|
};
|
|
4531
4510
|
|
|
4532
4511
|
const glue = group => {
|
|
4533
|
-
const glueNode = new
|
|
4512
|
+
const glueNode = new MathNode("mtd", []);
|
|
4534
4513
|
glueNode.style = { padding: "0", width: "50%" };
|
|
4535
4514
|
if (group.envClasses.includes("multline")) {
|
|
4536
4515
|
glueNode.style.width = "7.5%";
|
|
@@ -4553,7 +4532,7 @@ var temml = (function () {
|
|
|
4553
4532
|
: StyleLevel.DISPLAY;
|
|
4554
4533
|
|
|
4555
4534
|
for (let j = 0; j < rw.length; j++) {
|
|
4556
|
-
const mtd = new
|
|
4535
|
+
const mtd = new MathNode(
|
|
4557
4536
|
"mtd",
|
|
4558
4537
|
[buildGroup$1(rw[j], style.withLevel(cellLevel))]
|
|
4559
4538
|
);
|
|
@@ -4569,16 +4548,16 @@ var temml = (function () {
|
|
|
4569
4548
|
const numColumns = group.body[0].length;
|
|
4570
4549
|
// Fill out a short row with empty <mtd> elements.
|
|
4571
4550
|
for (let k = 0; k < numColumns - rw.length; k++) {
|
|
4572
|
-
row.push(new
|
|
4551
|
+
row.push(new MathNode("mtd", [], [], style));
|
|
4573
4552
|
}
|
|
4574
4553
|
if (group.autoTag) {
|
|
4575
4554
|
const tag = group.tags[i];
|
|
4576
4555
|
let tagElement;
|
|
4577
4556
|
if (tag === true) { // automatic numbering
|
|
4578
|
-
tagElement = new
|
|
4557
|
+
tagElement = new MathNode("mtext", [new Span(["tml-eqn"])]);
|
|
4579
4558
|
} else if (tag === false) {
|
|
4580
4559
|
// \nonumber/\notag or starred environment
|
|
4581
|
-
tagElement = new
|
|
4560
|
+
tagElement = new MathNode("mtext", [], []);
|
|
4582
4561
|
} else { // manual \tag
|
|
4583
4562
|
tagElement = buildExpressionRow(tag[0].body, style.withLevel(cellLevel), true);
|
|
4584
4563
|
tagElement = consolidateText(tagElement);
|
|
@@ -4594,7 +4573,7 @@ var temml = (function () {
|
|
|
4594
4573
|
}
|
|
4595
4574
|
}
|
|
4596
4575
|
}
|
|
4597
|
-
const mtr = new
|
|
4576
|
+
const mtr = new MathNode("mtr", row, []);
|
|
4598
4577
|
const label = group.labels.shift();
|
|
4599
4578
|
if (label && group.tags && group.tags[i]) {
|
|
4600
4579
|
mtr.setAttribute("id", label);
|
|
@@ -4736,7 +4715,7 @@ var temml = (function () {
|
|
|
4736
4715
|
}
|
|
4737
4716
|
}
|
|
4738
4717
|
|
|
4739
|
-
let table = new
|
|
4718
|
+
let table = new MathNode("mtable", tbl);
|
|
4740
4719
|
if (group.envClasses.length > 0) {
|
|
4741
4720
|
// Top & bottom padding
|
|
4742
4721
|
if (group.envClasses.includes("jot")) {
|
|
@@ -4820,7 +4799,7 @@ var temml = (function () {
|
|
|
4820
4799
|
|
|
4821
4800
|
if (group.envClasses.includes("small")) {
|
|
4822
4801
|
// A small array. Wrap in scriptstyle.
|
|
4823
|
-
table = new
|
|
4802
|
+
table = new MathNode("mstyle", [table]);
|
|
4824
4803
|
table.setAttribute("scriptlevel", "1");
|
|
4825
4804
|
}
|
|
4826
4805
|
|
|
@@ -5067,9 +5046,8 @@ var temml = (function () {
|
|
|
5067
5046
|
numArgs: 0
|
|
5068
5047
|
},
|
|
5069
5048
|
handler(context) {
|
|
5070
|
-
const payload = {
|
|
5049
|
+
const payload = { envClasses: ["small"] };
|
|
5071
5050
|
const res = parseArray(context.parser, payload, "script");
|
|
5072
|
-
res.envClasses = ["small"];
|
|
5073
5051
|
return res;
|
|
5074
5052
|
},
|
|
5075
5053
|
mathmlBuilder: mathmlBuilder$9
|
|
@@ -5486,13 +5464,13 @@ var temml = (function () {
|
|
|
5486
5464
|
// the color individually to each node and return a document fragment.
|
|
5487
5465
|
let expr = buildExpression(group.body, style.withColor(group.color));
|
|
5488
5466
|
if (expr.length === 0) {
|
|
5489
|
-
expr.push(new
|
|
5467
|
+
expr.push(new MathNode("mrow"));
|
|
5490
5468
|
}
|
|
5491
5469
|
expr = expr.map(e => {
|
|
5492
5470
|
e.style.color = group.color;
|
|
5493
5471
|
return e
|
|
5494
5472
|
});
|
|
5495
|
-
return
|
|
5473
|
+
return newDocumentFragment(expr)
|
|
5496
5474
|
};
|
|
5497
5475
|
|
|
5498
5476
|
defineFunction({
|
|
@@ -5613,7 +5591,7 @@ var temml = (function () {
|
|
|
5613
5591
|
mathmlBuilder(group, style) {
|
|
5614
5592
|
// MathML 3.0 calls for newline to occur in an <mo> or an <mspace>.
|
|
5615
5593
|
// Ref: https://www.w3.org/TR/MathML3/chapter3.html#presm.linebreaking
|
|
5616
|
-
const node = new
|
|
5594
|
+
const node = new MathNode("mo");
|
|
5617
5595
|
if (group.newLine) {
|
|
5618
5596
|
node.setAttribute("linebreak", "newline");
|
|
5619
5597
|
if (group.size) {
|
|
@@ -6068,7 +6046,7 @@ var temml = (function () {
|
|
|
6068
6046
|
if (group.delim === ".") { group.delim = ""; }
|
|
6069
6047
|
children.push(makeText(group.delim, group.mode));
|
|
6070
6048
|
|
|
6071
|
-
const node = new
|
|
6049
|
+
const node = new MathNode("mo", children);
|
|
6072
6050
|
|
|
6073
6051
|
if (group.mclass === "mopen" || group.mclass === "mclose") {
|
|
6074
6052
|
// Only some of the delimsizing functions act as fences, and they
|
|
@@ -6162,7 +6140,7 @@ var temml = (function () {
|
|
|
6162
6140
|
const inner = buildExpression(group.body, style);
|
|
6163
6141
|
|
|
6164
6142
|
if (group.left === ".") { group.left = ""; }
|
|
6165
|
-
const leftNode = new
|
|
6143
|
+
const leftNode = new MathNode("mo", [makeText(group.left, group.mode)]);
|
|
6166
6144
|
leftNode.setAttribute("fence", "true");
|
|
6167
6145
|
leftNode.setAttribute("form", "prefix");
|
|
6168
6146
|
if (group.left === "/" || group.left === "\u005C" || group.left.indexOf("arrow") > -1) {
|
|
@@ -6171,7 +6149,7 @@ var temml = (function () {
|
|
|
6171
6149
|
inner.unshift(leftNode);
|
|
6172
6150
|
|
|
6173
6151
|
if (group.right === ".") { group.right = ""; }
|
|
6174
|
-
const rightNode = new
|
|
6152
|
+
const rightNode = new MathNode("mo", [makeText(group.right, group.mode)]);
|
|
6175
6153
|
rightNode.setAttribute("fence", "true");
|
|
6176
6154
|
rightNode.setAttribute("form", "postfix");
|
|
6177
6155
|
if (group.right === "\u2216" || group.right.indexOf("arrow") > -1) {
|
|
@@ -6213,7 +6191,7 @@ var temml = (function () {
|
|
|
6213
6191
|
},
|
|
6214
6192
|
mathmlBuilder: (group, style) => {
|
|
6215
6193
|
const textNode = makeText(group.delim, group.mode);
|
|
6216
|
-
const middleNode = new
|
|
6194
|
+
const middleNode = new MathNode("mo", [textNode]);
|
|
6217
6195
|
middleNode.setAttribute("fence", "true");
|
|
6218
6196
|
if (group.delim.indexOf("arrow") > -1) {
|
|
6219
6197
|
middleNode.setAttribute("stretchy", "true");
|
|
@@ -6230,7 +6208,8 @@ var temml = (function () {
|
|
|
6230
6208
|
});
|
|
6231
6209
|
|
|
6232
6210
|
const mathmlBuilder$7 = (group, style) => {
|
|
6233
|
-
const
|
|
6211
|
+
const tag = group.label === "\\boxed" ? "mrow" : "menclose";
|
|
6212
|
+
const node = new MathNode(tag, [buildGroup$1(group.body, style)]);
|
|
6234
6213
|
switch (group.label) {
|
|
6235
6214
|
case "\\overline":
|
|
6236
6215
|
node.setAttribute("notation", "top"); // for Firefox & WebKit
|
|
@@ -6242,15 +6221,15 @@ var temml = (function () {
|
|
|
6242
6221
|
break
|
|
6243
6222
|
case "\\cancel":
|
|
6244
6223
|
node.setAttribute("notation", "updiagonalstrike");
|
|
6245
|
-
node.children.push(new
|
|
6224
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "upstrike"]));
|
|
6246
6225
|
break
|
|
6247
6226
|
case "\\bcancel":
|
|
6248
6227
|
node.setAttribute("notation", "downdiagonalstrike");
|
|
6249
|
-
node.children.push(new
|
|
6228
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "downstrike"]));
|
|
6250
6229
|
break
|
|
6251
6230
|
case "\\sout":
|
|
6252
6231
|
node.setAttribute("notation", "horizontalstrike");
|
|
6253
|
-
node.children.push(new
|
|
6232
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "sout"]));
|
|
6254
6233
|
break
|
|
6255
6234
|
case "\\xcancel":
|
|
6256
6235
|
node.setAttribute("notation", "updiagonalstrike downdiagonalstrike");
|
|
@@ -6259,17 +6238,17 @@ var temml = (function () {
|
|
|
6259
6238
|
case "\\longdiv":
|
|
6260
6239
|
node.setAttribute("notation", "longdiv");
|
|
6261
6240
|
node.classes.push("longdiv-top");
|
|
6262
|
-
node.children.push(new
|
|
6241
|
+
node.children.push(new MathNode("mrow", [], ["longdiv-arc"]));
|
|
6263
6242
|
break
|
|
6264
6243
|
case "\\phase":
|
|
6265
6244
|
node.setAttribute("notation", "phasorangle");
|
|
6266
6245
|
node.classes.push("phasor-bottom");
|
|
6267
|
-
node.children.push(new
|
|
6246
|
+
node.children.push(new MathNode("mrow", [], ["phasor-angle"]));
|
|
6268
6247
|
break
|
|
6269
6248
|
case "\\textcircled":
|
|
6270
6249
|
node.setAttribute("notation", "circle");
|
|
6271
6250
|
node.classes.push("circle-pad");
|
|
6272
|
-
node.children.push(new
|
|
6251
|
+
node.children.push(new MathNode("mrow", [], ["textcircle"]));
|
|
6273
6252
|
break
|
|
6274
6253
|
case "\\angl":
|
|
6275
6254
|
node.setAttribute("notation", "actuarial");
|
|
@@ -6277,7 +6256,6 @@ var temml = (function () {
|
|
|
6277
6256
|
break
|
|
6278
6257
|
case "\\boxed":
|
|
6279
6258
|
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
|
|
6280
|
-
node.setAttribute("notation", "box");
|
|
6281
6259
|
node.style.padding = "3pt";
|
|
6282
6260
|
node.style.border = "1px solid";
|
|
6283
6261
|
node.setAttribute("scriptlevel", "0");
|
|
@@ -6521,7 +6499,7 @@ var temml = (function () {
|
|
|
6521
6499
|
};
|
|
6522
6500
|
},
|
|
6523
6501
|
mathmlBuilder(group, style) {
|
|
6524
|
-
return new
|
|
6502
|
+
return new MathNode("mrow");
|
|
6525
6503
|
}
|
|
6526
6504
|
});
|
|
6527
6505
|
|
|
@@ -6538,7 +6516,7 @@ var temml = (function () {
|
|
|
6538
6516
|
};
|
|
6539
6517
|
},
|
|
6540
6518
|
mathmlBuilder(group, style) {
|
|
6541
|
-
return new
|
|
6519
|
+
return new MathNode("mrow");
|
|
6542
6520
|
}
|
|
6543
6521
|
});
|
|
6544
6522
|
|
|
@@ -6581,7 +6559,7 @@ var temml = (function () {
|
|
|
6581
6559
|
: mathGroup.children[i].children[0].text;
|
|
6582
6560
|
}
|
|
6583
6561
|
// Wrap in a <mpadded> to prevent the same Firefox bug.
|
|
6584
|
-
const mpadded = new
|
|
6562
|
+
const mpadded = new MathNode("mpadded", [mi]);
|
|
6585
6563
|
mpadded.setAttribute("lspace", "0");
|
|
6586
6564
|
return mpadded
|
|
6587
6565
|
}
|
|
@@ -6607,8 +6585,8 @@ var temml = (function () {
|
|
|
6607
6585
|
// Ref: https://bugs.webkit.org/show_bug.cgi?id=129097
|
|
6608
6586
|
// We insert a text node that contains a zero-width space and wrap in an mrow.
|
|
6609
6587
|
// TODO: Get rid of this <mi> workaround when the Firefox bug is fixed.
|
|
6610
|
-
const bogus = new
|
|
6611
|
-
return new
|
|
6588
|
+
const bogus = new MathNode("mtext", new TextNode("\u200b"));
|
|
6589
|
+
return new MathNode("mrow", [bogus, mi])
|
|
6612
6590
|
}
|
|
6613
6591
|
return mi
|
|
6614
6592
|
};
|
|
@@ -6719,7 +6697,7 @@ var temml = (function () {
|
|
|
6719
6697
|
denom.setAttribute("scriptlevel", "2");
|
|
6720
6698
|
}
|
|
6721
6699
|
|
|
6722
|
-
let node = new
|
|
6700
|
+
let node = new MathNode("mfrac", [numer, denom]);
|
|
6723
6701
|
|
|
6724
6702
|
if (!group.hasBarLine) {
|
|
6725
6703
|
node.setAttribute("linethickness", "0px");
|
|
@@ -6732,8 +6710,8 @@ var temml = (function () {
|
|
|
6732
6710
|
const withDelims = [];
|
|
6733
6711
|
|
|
6734
6712
|
if (group.leftDelim != null) {
|
|
6735
|
-
const leftOp = new
|
|
6736
|
-
new
|
|
6713
|
+
const leftOp = new MathNode("mo", [
|
|
6714
|
+
new TextNode(group.leftDelim.replace("\\", ""))
|
|
6737
6715
|
]);
|
|
6738
6716
|
leftOp.setAttribute("fence", "true");
|
|
6739
6717
|
withDelims.push(leftOp);
|
|
@@ -6742,8 +6720,8 @@ var temml = (function () {
|
|
|
6742
6720
|
withDelims.push(node);
|
|
6743
6721
|
|
|
6744
6722
|
if (group.rightDelim != null) {
|
|
6745
|
-
const rightOp = new
|
|
6746
|
-
new
|
|
6723
|
+
const rightOp = new MathNode("mo", [
|
|
6724
|
+
new TextNode(group.rightDelim.replace("\\", ""))
|
|
6747
6725
|
]);
|
|
6748
6726
|
rightOp.setAttribute("fence", "true");
|
|
6749
6727
|
withDelims.push(rightOp);
|
|
@@ -6753,7 +6731,7 @@ var temml = (function () {
|
|
|
6753
6731
|
}
|
|
6754
6732
|
|
|
6755
6733
|
if (group.scriptLevel !== "auto") {
|
|
6756
|
-
node = new
|
|
6734
|
+
node = new MathNode("mstyle", [node]);
|
|
6757
6735
|
node.setAttribute("displaystyle", String(group.scriptLevel === "display"));
|
|
6758
6736
|
node.setAttribute("scriptlevel", scriptLevel[group.scriptLevel]);
|
|
6759
6737
|
}
|
|
@@ -7056,9 +7034,9 @@ var temml = (function () {
|
|
|
7056
7034
|
});
|
|
7057
7035
|
|
|
7058
7036
|
const mathmlBuilder$4 = (group, style) => {
|
|
7059
|
-
const accentNode =
|
|
7037
|
+
const accentNode = mathMLnode(group.label);
|
|
7060
7038
|
accentNode.style["math-depth"] = 0;
|
|
7061
|
-
return new
|
|
7039
|
+
return new MathNode(group.isOver ? "mover" : "munder", [
|
|
7062
7040
|
buildGroup$1(group.base, style),
|
|
7063
7041
|
accentNode
|
|
7064
7042
|
]);
|
|
@@ -7294,7 +7272,7 @@ var temml = (function () {
|
|
|
7294
7272
|
const node = new Img(group.src, group.alt, graphicStyle);
|
|
7295
7273
|
node.height = height;
|
|
7296
7274
|
node.depth = depth;
|
|
7297
|
-
return new
|
|
7275
|
+
return new MathNode("mtext", [node])
|
|
7298
7276
|
}
|
|
7299
7277
|
});
|
|
7300
7278
|
|
|
@@ -7344,17 +7322,17 @@ var temml = (function () {
|
|
|
7344
7322
|
? spaceCharacter(dimension.number)
|
|
7345
7323
|
: "";
|
|
7346
7324
|
if (group.mode === "text" && ch.length > 0) {
|
|
7347
|
-
const character = new
|
|
7348
|
-
return new
|
|
7325
|
+
const character = new TextNode(ch);
|
|
7326
|
+
return new MathNode("mtext", [character]);
|
|
7349
7327
|
} else {
|
|
7350
7328
|
if (dimension.number >= 0) {
|
|
7351
|
-
const node = new
|
|
7329
|
+
const node = new MathNode("mspace");
|
|
7352
7330
|
node.setAttribute("width", dimension.number + dimension.unit);
|
|
7353
7331
|
return node
|
|
7354
7332
|
} else {
|
|
7355
7333
|
// Don't use <mspace> or <mpadded> because
|
|
7356
7334
|
// WebKit recognizes negative left margin only on a <mrow> element
|
|
7357
|
-
const node = new
|
|
7335
|
+
const node = new MathNode("mrow");
|
|
7358
7336
|
node.style.marginLeft = dimension.number + dimension.unit;
|
|
7359
7337
|
return node
|
|
7360
7338
|
}
|
|
@@ -7395,7 +7373,7 @@ var temml = (function () {
|
|
|
7395
7373
|
},
|
|
7396
7374
|
mathmlBuilder(group, style) {
|
|
7397
7375
|
// Return a no-width, no-ink element with an HTML id.
|
|
7398
|
-
const node = new
|
|
7376
|
+
const node = new MathNode("mrow", [], ["tml-label"]);
|
|
7399
7377
|
if (group.string.length > 0) {
|
|
7400
7378
|
node.setLabel(group.string);
|
|
7401
7379
|
}
|
|
@@ -7439,8 +7417,8 @@ var temml = (function () {
|
|
|
7439
7417
|
// We need an invisible strut with the same depth as the group.
|
|
7440
7418
|
// We can't just read the depth, so we use \vphantom methods.
|
|
7441
7419
|
const phantomInner = buildExpression(ordargument(group.body), style);
|
|
7442
|
-
const phantom = new
|
|
7443
|
-
strut = new
|
|
7420
|
+
const phantom = new MathNode("mphantom", phantomInner);
|
|
7421
|
+
strut = new MathNode("mpadded", [phantom]);
|
|
7444
7422
|
strut.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
7445
7423
|
}
|
|
7446
7424
|
|
|
@@ -7450,9 +7428,9 @@ var temml = (function () {
|
|
|
7450
7428
|
inner.style.position = "absolute";
|
|
7451
7429
|
inner.style.right = "0";
|
|
7452
7430
|
inner.style.bottom = `0`; // If we could have read the ink depth, it would go here.
|
|
7453
|
-
node = new
|
|
7431
|
+
node = new MathNode("mpadded", [strut, inner]);
|
|
7454
7432
|
} else {
|
|
7455
|
-
node = new
|
|
7433
|
+
node = new MathNode("mpadded", [inner]);
|
|
7456
7434
|
}
|
|
7457
7435
|
|
|
7458
7436
|
if (group.alignment === "rlap") {
|
|
@@ -7558,7 +7536,7 @@ var temml = (function () {
|
|
|
7558
7536
|
const inner = buildExpression(group.body, style);
|
|
7559
7537
|
|
|
7560
7538
|
if (group.mclass === "minner") {
|
|
7561
|
-
node = new
|
|
7539
|
+
node = new MathNode("mpadded", inner);
|
|
7562
7540
|
} else if (group.mclass === "mord") {
|
|
7563
7541
|
if (group.isCharacterBox || inner[0].type === "mathord") {
|
|
7564
7542
|
node = inner[0];
|
|
@@ -7567,10 +7545,10 @@ var temml = (function () {
|
|
|
7567
7545
|
node.setAttribute("mathvariant", "normal");
|
|
7568
7546
|
}
|
|
7569
7547
|
} else {
|
|
7570
|
-
node = new
|
|
7548
|
+
node = new MathNode("mi", inner);
|
|
7571
7549
|
}
|
|
7572
7550
|
} else {
|
|
7573
|
-
node = new
|
|
7551
|
+
node = new MathNode("mrow", inner);
|
|
7574
7552
|
if (group.mustPromote) {
|
|
7575
7553
|
node = inner[0];
|
|
7576
7554
|
node.type = "mo";
|
|
@@ -7578,7 +7556,7 @@ var temml = (function () {
|
|
|
7578
7556
|
node.setAttribute("mathvariant", "italic");
|
|
7579
7557
|
}
|
|
7580
7558
|
} else {
|
|
7581
|
-
node = new
|
|
7559
|
+
node = new MathNode("mrow", inner);
|
|
7582
7560
|
}
|
|
7583
7561
|
|
|
7584
7562
|
// Set spacing based on what is the most likely adjacent atom type.
|
|
@@ -7648,7 +7626,7 @@ var temml = (function () {
|
|
|
7648
7626
|
},
|
|
7649
7627
|
handler({ parser, funcName }, args) {
|
|
7650
7628
|
const body = args[0];
|
|
7651
|
-
const isCharacterBox =
|
|
7629
|
+
const isCharacterBox$1 = isCharacterBox(body);
|
|
7652
7630
|
// We should not wrap a <mo> around a <mi> or <mord>. That would be invalid MathML.
|
|
7653
7631
|
// In that case, we instead promote the text contents of the body to the parent.
|
|
7654
7632
|
let mustPromote = true;
|
|
@@ -7677,7 +7655,7 @@ var temml = (function () {
|
|
|
7677
7655
|
mode: parser.mode,
|
|
7678
7656
|
mclass: "m" + funcName.slice(5),
|
|
7679
7657
|
body: ordargument(mustPromote ? mord : body),
|
|
7680
|
-
isCharacterBox,
|
|
7658
|
+
isCharacterBox: isCharacterBox$1,
|
|
7681
7659
|
mustPromote
|
|
7682
7660
|
};
|
|
7683
7661
|
}
|
|
@@ -7714,7 +7692,7 @@ var temml = (function () {
|
|
|
7714
7692
|
mode: parser.mode,
|
|
7715
7693
|
mclass: binrelClass(args[0]),
|
|
7716
7694
|
body: ordargument(args[1]),
|
|
7717
|
-
isCharacterBox:
|
|
7695
|
+
isCharacterBox: isCharacterBox(args[1])
|
|
7718
7696
|
};
|
|
7719
7697
|
}
|
|
7720
7698
|
});
|
|
@@ -7828,8 +7806,8 @@ var temml = (function () {
|
|
|
7828
7806
|
mathmlBuilder(group, style) {
|
|
7829
7807
|
const base = buildGroup$1(group.base, style);
|
|
7830
7808
|
|
|
7831
|
-
const prescriptsNode = new
|
|
7832
|
-
const noneNode = new
|
|
7809
|
+
const prescriptsNode = new MathNode("mprescripts");
|
|
7810
|
+
const noneNode = new MathNode("none");
|
|
7833
7811
|
let children = [];
|
|
7834
7812
|
|
|
7835
7813
|
const preSub = buildGroup(group.prescripts.sub, style, noneNode);
|
|
@@ -7848,7 +7826,7 @@ var temml = (function () {
|
|
|
7848
7826
|
children = [base, prescriptsNode, preSub, preSup];
|
|
7849
7827
|
}
|
|
7850
7828
|
|
|
7851
|
-
return new
|
|
7829
|
+
return new MathNode("mmultiscripts", children);
|
|
7852
7830
|
}
|
|
7853
7831
|
});
|
|
7854
7832
|
|
|
@@ -7861,9 +7839,9 @@ var temml = (function () {
|
|
|
7861
7839
|
allowedInText: false
|
|
7862
7840
|
},
|
|
7863
7841
|
handler({ parser }, args) {
|
|
7864
|
-
const isCharacterBox =
|
|
7842
|
+
const isCharacterBox$1 = isCharacterBox(args[0]);
|
|
7865
7843
|
let body;
|
|
7866
|
-
if (isCharacterBox) {
|
|
7844
|
+
if (isCharacterBox$1) {
|
|
7867
7845
|
body = ordargument(args[0]);
|
|
7868
7846
|
if (body[0].text.charAt(0) === "\\") {
|
|
7869
7847
|
body[0].text = symbols.math[body[0].text].replace;
|
|
@@ -7881,7 +7859,7 @@ var temml = (function () {
|
|
|
7881
7859
|
type: "not",
|
|
7882
7860
|
mode: parser.mode,
|
|
7883
7861
|
body,
|
|
7884
|
-
isCharacterBox
|
|
7862
|
+
isCharacterBox: isCharacterBox$1
|
|
7885
7863
|
};
|
|
7886
7864
|
},
|
|
7887
7865
|
mathmlBuilder(group, style) {
|
|
@@ -8260,9 +8238,9 @@ var temml = (function () {
|
|
|
8260
8238
|
let isAllString = true; // default
|
|
8261
8239
|
for (let i = 0; i < expression.length; i++) {
|
|
8262
8240
|
let node = expression[i];
|
|
8263
|
-
if (node instanceof
|
|
8241
|
+
if (node instanceof MathNode) {
|
|
8264
8242
|
if ((node.type === "mrow" || node.type === "mpadded") && node.children.length === 1 &&
|
|
8265
|
-
node.children[0] instanceof
|
|
8243
|
+
node.children[0] instanceof MathNode) {
|
|
8266
8244
|
node = node.children[0];
|
|
8267
8245
|
}
|
|
8268
8246
|
switch (node.type) {
|
|
@@ -8279,14 +8257,14 @@ var temml = (function () {
|
|
|
8279
8257
|
if (ch === "") {
|
|
8280
8258
|
isAllString = false;
|
|
8281
8259
|
} else {
|
|
8282
|
-
expression[i] = new
|
|
8260
|
+
expression[i] = new MathNode("mtext", [new TextNode(ch)]);
|
|
8283
8261
|
}
|
|
8284
8262
|
}
|
|
8285
8263
|
}
|
|
8286
8264
|
break
|
|
8287
8265
|
case "mo": {
|
|
8288
8266
|
const child = node.children[0];
|
|
8289
|
-
if (node.children.length === 1 && child instanceof
|
|
8267
|
+
if (node.children.length === 1 && child instanceof TextNode) {
|
|
8290
8268
|
child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
|
|
8291
8269
|
} else {
|
|
8292
8270
|
isAllString = false;
|
|
@@ -8304,7 +8282,7 @@ var temml = (function () {
|
|
|
8304
8282
|
if (isAllString) {
|
|
8305
8283
|
// Write a single TextNode instead of multiple nested tags.
|
|
8306
8284
|
const word = expression.map((node) => node.toText()).join("");
|
|
8307
|
-
expression = [new
|
|
8285
|
+
expression = [new TextNode(word)];
|
|
8308
8286
|
} else if (
|
|
8309
8287
|
expression.length === 1
|
|
8310
8288
|
&& ["mover", "munder"].includes(expression[0].type) &&
|
|
@@ -8312,41 +8290,41 @@ var temml = (function () {
|
|
|
8312
8290
|
) {
|
|
8313
8291
|
expression[0].children[0].type = "mi";
|
|
8314
8292
|
if (group.parentIsSupSub) {
|
|
8315
|
-
return new
|
|
8293
|
+
return new MathNode("mrow", expression)
|
|
8316
8294
|
} else {
|
|
8317
|
-
const operator = new
|
|
8318
|
-
return
|
|
8295
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
8296
|
+
return newDocumentFragment([expression[0], operator])
|
|
8319
8297
|
}
|
|
8320
8298
|
}
|
|
8321
8299
|
|
|
8322
8300
|
let wrapper;
|
|
8323
8301
|
if (isAllString) {
|
|
8324
|
-
wrapper = new
|
|
8302
|
+
wrapper = new MathNode("mi", expression);
|
|
8325
8303
|
if (expression[0].text.length === 1) {
|
|
8326
8304
|
wrapper.setAttribute("mathvariant", "normal");
|
|
8327
8305
|
}
|
|
8328
8306
|
} else {
|
|
8329
|
-
wrapper = new
|
|
8307
|
+
wrapper = new MathNode("mrow", expression);
|
|
8330
8308
|
}
|
|
8331
8309
|
|
|
8332
8310
|
if (!group.parentIsSupSub) {
|
|
8333
8311
|
// Append an <mo>⁡</mo>.
|
|
8334
8312
|
// ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
|
|
8335
|
-
const operator = new
|
|
8313
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
8336
8314
|
const fragment = [wrapper, operator];
|
|
8337
8315
|
if (group.needsLeadingSpace) {
|
|
8338
8316
|
// LaTeX gives operator spacing, but a <mi> gets ord spacing.
|
|
8339
8317
|
// So add a leading space.
|
|
8340
|
-
const space = new
|
|
8318
|
+
const space = new MathNode("mspace");
|
|
8341
8319
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
8342
8320
|
fragment.unshift(space);
|
|
8343
8321
|
}
|
|
8344
8322
|
if (!group.isFollowedByDelimiter) {
|
|
8345
|
-
const trail = new
|
|
8323
|
+
const trail = new MathNode("mspace");
|
|
8346
8324
|
trail.setAttribute("width", "0.1667em"); // thin space.
|
|
8347
8325
|
fragment.push(trail);
|
|
8348
8326
|
}
|
|
8349
|
-
return
|
|
8327
|
+
return newDocumentFragment(fragment)
|
|
8350
8328
|
}
|
|
8351
8329
|
|
|
8352
8330
|
return wrapper
|
|
@@ -8406,7 +8384,7 @@ var temml = (function () {
|
|
|
8406
8384
|
},
|
|
8407
8385
|
mathmlBuilder: (group, style) => {
|
|
8408
8386
|
const inner = buildExpression(group.body, style);
|
|
8409
|
-
return new
|
|
8387
|
+
return new MathNode("mphantom", inner);
|
|
8410
8388
|
}
|
|
8411
8389
|
});
|
|
8412
8390
|
|
|
@@ -8427,8 +8405,8 @@ var temml = (function () {
|
|
|
8427
8405
|
},
|
|
8428
8406
|
mathmlBuilder: (group, style) => {
|
|
8429
8407
|
const inner = buildExpression(ordargument(group.body), style);
|
|
8430
|
-
const phantom = new
|
|
8431
|
-
const node = new
|
|
8408
|
+
const phantom = new MathNode("mphantom", inner);
|
|
8409
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
8432
8410
|
node.setAttribute("height", "0px");
|
|
8433
8411
|
node.setAttribute("depth", "0px");
|
|
8434
8412
|
return node;
|
|
@@ -8452,8 +8430,8 @@ var temml = (function () {
|
|
|
8452
8430
|
},
|
|
8453
8431
|
mathmlBuilder: (group, style) => {
|
|
8454
8432
|
const inner = buildExpression(ordargument(group.body), style);
|
|
8455
|
-
const phantom = new
|
|
8456
|
-
const node = new
|
|
8433
|
+
const phantom = new MathNode("mphantom", inner);
|
|
8434
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
8457
8435
|
node.setAttribute("width", "0px");
|
|
8458
8436
|
return node;
|
|
8459
8437
|
}
|
|
@@ -8490,7 +8468,7 @@ var temml = (function () {
|
|
|
8490
8468
|
|
|
8491
8469
|
const mathmlBuilder = (group, style) => {
|
|
8492
8470
|
const newStyle = style.withLevel(StyleLevel.TEXT);
|
|
8493
|
-
const node = new
|
|
8471
|
+
const node = new MathNode("mpadded", [buildGroup$1(group.body, newStyle)]);
|
|
8494
8472
|
const dy = calculateSize(group.dy, style);
|
|
8495
8473
|
node.setAttribute("voffset", dy.number + dy.unit);
|
|
8496
8474
|
// Add padding, which acts to increase height in Chromium.
|
|
@@ -8638,7 +8616,7 @@ var temml = (function () {
|
|
|
8638
8616
|
: { number: 0, unit: "em" };
|
|
8639
8617
|
const color = (style.color && style.getColor()) || "black";
|
|
8640
8618
|
|
|
8641
|
-
const rule = new
|
|
8619
|
+
const rule = new MathNode("mspace");
|
|
8642
8620
|
if (width.number > 0 && height.number > 0) {
|
|
8643
8621
|
rule.setAttribute("mathbackground", color);
|
|
8644
8622
|
}
|
|
@@ -8646,7 +8624,7 @@ var temml = (function () {
|
|
|
8646
8624
|
rule.setAttribute("height", height.number + height.unit);
|
|
8647
8625
|
if (shift.number === 0) { return rule }
|
|
8648
8626
|
|
|
8649
|
-
const wrapper = new
|
|
8627
|
+
const wrapper = new MathNode("mpadded", [rule]);
|
|
8650
8628
|
if (shift.number >= 0) {
|
|
8651
8629
|
wrapper.setAttribute("height", "+" + shift.number + shift.unit);
|
|
8652
8630
|
} else {
|
|
@@ -8718,8 +8696,8 @@ var temml = (function () {
|
|
|
8718
8696
|
const numerator = group.numerator.split('').map(c => unicodeNumSups[c]).join('');
|
|
8719
8697
|
const denominator = group.denominator.split('').map(c => unicodeNumSubs[c]).join('');
|
|
8720
8698
|
// Use a fraction slash.
|
|
8721
|
-
const text = new
|
|
8722
|
-
return new
|
|
8699
|
+
const text = new TextNode(numerator + "\u2044" + denominator, group.mode, style);
|
|
8700
|
+
return new MathNode("mn", [text], ["special-fraction"])
|
|
8723
8701
|
}
|
|
8724
8702
|
});
|
|
8725
8703
|
|
|
@@ -8832,7 +8810,7 @@ var temml = (function () {
|
|
|
8832
8810
|
};
|
|
8833
8811
|
},
|
|
8834
8812
|
mathmlBuilder: (group, style) => {
|
|
8835
|
-
const node = new
|
|
8813
|
+
const node = new MathNode("mpadded", [buildGroup$1(group.body, style)]);
|
|
8836
8814
|
|
|
8837
8815
|
if (group.smashHeight) {
|
|
8838
8816
|
node.setAttribute("height", "0px");
|
|
@@ -8885,11 +8863,11 @@ var temml = (function () {
|
|
|
8885
8863
|
mathmlBuilder(group, style) {
|
|
8886
8864
|
const { body, index } = group;
|
|
8887
8865
|
return index
|
|
8888
|
-
? new
|
|
8866
|
+
? new MathNode("mroot", [
|
|
8889
8867
|
buildGroup$1(body, style),
|
|
8890
8868
|
buildGroup$1(index, style.incrementLevel())
|
|
8891
8869
|
])
|
|
8892
|
-
: new
|
|
8870
|
+
: new MathNode("msqrt", [buildGroup$1(body, style)]);
|
|
8893
8871
|
}
|
|
8894
8872
|
});
|
|
8895
8873
|
|
|
@@ -9088,26 +9066,26 @@ var temml = (function () {
|
|
|
9088
9066
|
}
|
|
9089
9067
|
}
|
|
9090
9068
|
|
|
9091
|
-
let node = new
|
|
9069
|
+
let node = new MathNode(nodeType, children);
|
|
9092
9070
|
if (appendApplyFunction) {
|
|
9093
9071
|
// Append an <mo>⁡</mo>.
|
|
9094
9072
|
// ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
|
|
9095
|
-
const operator = new
|
|
9073
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
9096
9074
|
if (needsLeadingSpace) {
|
|
9097
|
-
const space = new
|
|
9075
|
+
const space = new MathNode("mspace");
|
|
9098
9076
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
9099
|
-
node =
|
|
9077
|
+
node = newDocumentFragment([space, node, operator]);
|
|
9100
9078
|
} else {
|
|
9101
|
-
node =
|
|
9079
|
+
node = newDocumentFragment([node, operator]);
|
|
9102
9080
|
}
|
|
9103
9081
|
if (appendSpace) {
|
|
9104
|
-
const space = new
|
|
9082
|
+
const space = new MathNode("mspace");
|
|
9105
9083
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
9106
9084
|
node.children.push(space);
|
|
9107
9085
|
}
|
|
9108
9086
|
} else if (symbolRegEx.test(nodeType)) {
|
|
9109
9087
|
// Wrap in a <mrow>. Otherwise Firefox stretchy parens will not stretch to include limits.
|
|
9110
|
-
node = new
|
|
9088
|
+
node = new MathNode("mrow", [node]);
|
|
9111
9089
|
}
|
|
9112
9090
|
|
|
9113
9091
|
return node
|
|
@@ -9132,7 +9110,7 @@ var temml = (function () {
|
|
|
9132
9110
|
defineFunctionBuilders({
|
|
9133
9111
|
type: "atom",
|
|
9134
9112
|
mathmlBuilder(group, style) {
|
|
9135
|
-
const node = new
|
|
9113
|
+
const node = new MathNode("mo", [makeText(group.text, group.mode)]);
|
|
9136
9114
|
if (group.family === "punct") {
|
|
9137
9115
|
node.setAttribute("separator", "true");
|
|
9138
9116
|
} else if (group.family === "open" || group.family === "close") {
|
|
@@ -9162,10 +9140,10 @@ var temml = (function () {
|
|
|
9162
9140
|
} else if (group.needsSpacing) {
|
|
9163
9141
|
// Fix a MathML bug that occurs when a <mo> is between two <mtext> elements.
|
|
9164
9142
|
if (group.family === "bin") {
|
|
9165
|
-
return new
|
|
9143
|
+
return new MathNode("mrow", [padding(0.222), node, padding(0.222)])
|
|
9166
9144
|
} else {
|
|
9167
9145
|
// REL spacing
|
|
9168
|
-
return new
|
|
9146
|
+
return new MathNode("mrow", [padding(0.2778), node, padding(0.2778)])
|
|
9169
9147
|
}
|
|
9170
9148
|
}
|
|
9171
9149
|
return node;
|
|
@@ -9506,8 +9484,8 @@ var temml = (function () {
|
|
|
9506
9484
|
"\\backprime", "\\backdprime", "\\backtrprime"]);
|
|
9507
9485
|
|
|
9508
9486
|
const italicNumber = (text, variant, tag) => {
|
|
9509
|
-
const mn = new
|
|
9510
|
-
const wrapper = new
|
|
9487
|
+
const mn = new MathNode(tag, [text]);
|
|
9488
|
+
const wrapper = new MathNode("mstyle", [mn]);
|
|
9511
9489
|
wrapper.style["font-style"] = "italic";
|
|
9512
9490
|
wrapper.style["font-family"] = "Cambria, 'Times New Roman', serif";
|
|
9513
9491
|
if (variant === "bold-italic") { wrapper.style["font-weight"] = "bold"; }
|
|
@@ -9524,17 +9502,17 @@ var temml = (function () {
|
|
|
9524
9502
|
const variant = getVariant(group, style) || defaultVariant;
|
|
9525
9503
|
if (variant === "script") {
|
|
9526
9504
|
text.text = variantChar(text.text, variant);
|
|
9527
|
-
return new
|
|
9505
|
+
return new MathNode("mi", [text], [style.font])
|
|
9528
9506
|
} else if (variant !== "italic") {
|
|
9529
9507
|
text.text = variantChar(text.text, variant);
|
|
9530
9508
|
}
|
|
9531
|
-
let node = new
|
|
9509
|
+
let node = new MathNode("mi", [text]);
|
|
9532
9510
|
// TODO: Handle U+1D49C - U+1D4CF per https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
9533
9511
|
if (variant === "normal") {
|
|
9534
9512
|
node.setAttribute("mathvariant", "normal");
|
|
9535
9513
|
if (text.text.length === 1) {
|
|
9536
9514
|
// A Firefox bug will apply spacing here, but there should be none. Fix it.
|
|
9537
|
-
node = new
|
|
9515
|
+
node = new MathNode("mpadded", [node]);
|
|
9538
9516
|
node.setAttribute("lspace", "0");
|
|
9539
9517
|
}
|
|
9540
9518
|
}
|
|
@@ -9565,15 +9543,15 @@ var temml = (function () {
|
|
|
9565
9543
|
if (variant !== "normal") {
|
|
9566
9544
|
text.text = text.text.split("").map(c => variantChar(c, variant)).join("");
|
|
9567
9545
|
}
|
|
9568
|
-
node = new
|
|
9546
|
+
node = new MathNode(tag, [text]);
|
|
9569
9547
|
}
|
|
9570
9548
|
} else if (group.mode === "text") {
|
|
9571
9549
|
if (variant !== "normal") {
|
|
9572
9550
|
text.text = variantChar(text.text, variant);
|
|
9573
9551
|
}
|
|
9574
|
-
node = new
|
|
9552
|
+
node = new MathNode("mtext", [text]);
|
|
9575
9553
|
} else if (primes.has(group.text)) {
|
|
9576
|
-
node = new
|
|
9554
|
+
node = new MathNode("mo", [text]);
|
|
9577
9555
|
// TODO: If/when Chromium uses ssty variant for prime, remove the next line.
|
|
9578
9556
|
node.classes.push("tml-prime");
|
|
9579
9557
|
} else {
|
|
@@ -9581,7 +9559,7 @@ var temml = (function () {
|
|
|
9581
9559
|
if (variant !== "italic") {
|
|
9582
9560
|
text.text = variantChar(text.text, variant);
|
|
9583
9561
|
}
|
|
9584
|
-
node = new
|
|
9562
|
+
node = new MathNode("mi", [text]);
|
|
9585
9563
|
if (text.text === origText && latinRegEx.test(origText)) {
|
|
9586
9564
|
node.setAttribute("mathvariant", "italic");
|
|
9587
9565
|
}
|
|
@@ -9624,11 +9602,11 @@ var temml = (function () {
|
|
|
9624
9602
|
// Firefox does not render a space in a <mtext> </mtext>. So write a no-break space.
|
|
9625
9603
|
// TODO: If Firefox fixes that bug, uncomment the next line and write ch into the node.
|
|
9626
9604
|
//const ch = (regularSpace[group.text].className === "nobreak") ? "\u00a0" : " "
|
|
9627
|
-
node = new
|
|
9605
|
+
node = new MathNode("mtext", [new TextNode("\u00a0")]);
|
|
9628
9606
|
} else if (Object.prototype.hasOwnProperty.call(cssSpace, group.text)) {
|
|
9629
9607
|
// MathML 3.0 calls for nobreak to occur in an <mo>, not an <mtext>
|
|
9630
9608
|
// Ref: https://www.w3.org/Math/draft-spec/mathml.html#chapter3_presm.lbattrs
|
|
9631
|
-
node = new
|
|
9609
|
+
node = new MathNode("mo");
|
|
9632
9610
|
if (group.text === "\\nobreak") {
|
|
9633
9611
|
node.setAttribute("linebreak", "nobreak");
|
|
9634
9612
|
}
|
|
@@ -9743,10 +9721,10 @@ var temml = (function () {
|
|
|
9743
9721
|
},
|
|
9744
9722
|
mathmlBuilder(group, style) {
|
|
9745
9723
|
// Use a math table to create vertically centered content.
|
|
9746
|
-
const mtd = new
|
|
9724
|
+
const mtd = new MathNode("mtd", [buildGroup$1(group.body, style)]);
|
|
9747
9725
|
mtd.style.padding = "0";
|
|
9748
|
-
const mtr = new
|
|
9749
|
-
return new
|
|
9726
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
9727
|
+
return new MathNode("mtable", [mtr])
|
|
9750
9728
|
}
|
|
9751
9729
|
});
|
|
9752
9730
|
|
|
@@ -9765,8 +9743,8 @@ var temml = (function () {
|
|
|
9765
9743
|
throw new ParseError("\\verb ended by end of line instead of matching delimiter");
|
|
9766
9744
|
},
|
|
9767
9745
|
mathmlBuilder(group, style) {
|
|
9768
|
-
const text = new
|
|
9769
|
-
const node = new
|
|
9746
|
+
const text = new TextNode(makeVerb(group));
|
|
9747
|
+
const node = new MathNode("mtext", [text]);
|
|
9770
9748
|
node.setAttribute("mathvariant", "monospace");
|
|
9771
9749
|
return node;
|
|
9772
9750
|
}
|
|
@@ -12098,7 +12076,7 @@ var temml = (function () {
|
|
|
12098
12076
|
* https://mit-license.org/
|
|
12099
12077
|
*/
|
|
12100
12078
|
|
|
12101
|
-
const version = "0.
|
|
12079
|
+
const version = "0.12.01";
|
|
12102
12080
|
|
|
12103
12081
|
function postProcess(block) {
|
|
12104
12082
|
const labelMap = {};
|