temml 0.11.10 → 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 +229 -268
- package/dist/temml.d.ts +2 -2
- package/dist/temml.js +229 -268
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +229 -268
- 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 +4 -1
- package/src/functions/enclose.js +6 -26
- 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 + "'")
|
|
@@ -2808,31 +2787,31 @@ var temml = (function () {
|
|
|
2808
2787
|
|
|
2809
2788
|
// Helper functions
|
|
2810
2789
|
|
|
2811
|
-
const padding
|
|
2812
|
-
const node = new
|
|
2790
|
+
const padding = width => {
|
|
2791
|
+
const node = new MathNode("mspace");
|
|
2813
2792
|
node.setAttribute("width", width + "em");
|
|
2814
2793
|
return node
|
|
2815
2794
|
};
|
|
2816
2795
|
|
|
2817
2796
|
const paddedNode = (group, lspace = 0.3, rspace = 0, mustSmash = false) => {
|
|
2818
|
-
if (group == null && rspace === 0) { return padding
|
|
2797
|
+
if (group == null && rspace === 0) { return padding(lspace) }
|
|
2819
2798
|
const row = group ? [group] : [];
|
|
2820
|
-
if (lspace !== 0) { row.unshift(padding
|
|
2821
|
-
if (rspace > 0) { row.push(padding
|
|
2799
|
+
if (lspace !== 0) { row.unshift(padding(lspace)); }
|
|
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
|
|
@@ -2950,9 +2929,9 @@ var temml = (function () {
|
|
|
2950
2929
|
const node = munderoverNode(group.name, group.body, group.below, style);
|
|
2951
2930
|
// Create operator spacing for a relation.
|
|
2952
2931
|
const row = [node];
|
|
2953
|
-
row.unshift(padding
|
|
2954
|
-
row.push(padding
|
|
2955
|
-
return new
|
|
2932
|
+
row.unshift(padding(0.2778));
|
|
2933
|
+
row.push(padding(0.2778));
|
|
2934
|
+
return new MathNode("mrow", row)
|
|
2956
2935
|
}
|
|
2957
2936
|
});
|
|
2958
2937
|
|
|
@@ -3005,23 +2984,23 @@ 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
|
-
[padding
|
|
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
|
-
[padding
|
|
3003
|
+
[padding(0.2778), raiseNode, botArrow, padding(0.2778)]
|
|
3025
3004
|
);
|
|
3026
3005
|
}
|
|
3027
3006
|
|
|
@@ -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) {
|
|
@@ -5995,6 +5973,9 @@ var temml = (function () {
|
|
|
5995
5973
|
|
|
5996
5974
|
// Delimiter functions
|
|
5997
5975
|
function checkDelimiter(delim, context) {
|
|
5976
|
+
if (delim.type === "ordgroup" && delim.body.length === 1) {
|
|
5977
|
+
delim = delim.body[0]; // Unwrap the braces
|
|
5978
|
+
}
|
|
5998
5979
|
const symDelim = checkSymbolNodeType(delim);
|
|
5999
5980
|
if (symDelim && delimiters.includes(symDelim.text)) {
|
|
6000
5981
|
// If a character is not in the MathML operator dictionary, it will not stretch.
|
|
@@ -6065,7 +6046,7 @@ var temml = (function () {
|
|
|
6065
6046
|
if (group.delim === ".") { group.delim = ""; }
|
|
6066
6047
|
children.push(makeText(group.delim, group.mode));
|
|
6067
6048
|
|
|
6068
|
-
const node = new
|
|
6049
|
+
const node = new MathNode("mo", children);
|
|
6069
6050
|
|
|
6070
6051
|
if (group.mclass === "mopen" || group.mclass === "mclose") {
|
|
6071
6052
|
// Only some of the delimsizing functions act as fences, and they
|
|
@@ -6159,7 +6140,7 @@ var temml = (function () {
|
|
|
6159
6140
|
const inner = buildExpression(group.body, style);
|
|
6160
6141
|
|
|
6161
6142
|
if (group.left === ".") { group.left = ""; }
|
|
6162
|
-
const leftNode = new
|
|
6143
|
+
const leftNode = new MathNode("mo", [makeText(group.left, group.mode)]);
|
|
6163
6144
|
leftNode.setAttribute("fence", "true");
|
|
6164
6145
|
leftNode.setAttribute("form", "prefix");
|
|
6165
6146
|
if (group.left === "/" || group.left === "\u005C" || group.left.indexOf("arrow") > -1) {
|
|
@@ -6168,7 +6149,7 @@ var temml = (function () {
|
|
|
6168
6149
|
inner.unshift(leftNode);
|
|
6169
6150
|
|
|
6170
6151
|
if (group.right === ".") { group.right = ""; }
|
|
6171
|
-
const rightNode = new
|
|
6152
|
+
const rightNode = new MathNode("mo", [makeText(group.right, group.mode)]);
|
|
6172
6153
|
rightNode.setAttribute("fence", "true");
|
|
6173
6154
|
rightNode.setAttribute("form", "postfix");
|
|
6174
6155
|
if (group.right === "\u2216" || group.right.indexOf("arrow") > -1) {
|
|
@@ -6210,7 +6191,7 @@ var temml = (function () {
|
|
|
6210
6191
|
},
|
|
6211
6192
|
mathmlBuilder: (group, style) => {
|
|
6212
6193
|
const textNode = makeText(group.delim, group.mode);
|
|
6213
|
-
const middleNode = new
|
|
6194
|
+
const middleNode = new MathNode("mo", [textNode]);
|
|
6214
6195
|
middleNode.setAttribute("fence", "true");
|
|
6215
6196
|
if (group.delim.indexOf("arrow") > -1) {
|
|
6216
6197
|
middleNode.setAttribute("stretchy", "true");
|
|
@@ -6226,26 +6207,9 @@ var temml = (function () {
|
|
|
6226
6207
|
}
|
|
6227
6208
|
});
|
|
6228
6209
|
|
|
6229
|
-
const padding = _ => {
|
|
6230
|
-
const node = new mathMLTree.MathNode("mspace");
|
|
6231
|
-
node.setAttribute("width", "3pt");
|
|
6232
|
-
return node
|
|
6233
|
-
};
|
|
6234
|
-
|
|
6235
6210
|
const mathmlBuilder$7 = (group, style) => {
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
// MathML core does not support +width attribute in <mpadded>.
|
|
6239
|
-
// Firefox does not reliably add side padding.
|
|
6240
|
-
// Insert <mspace>
|
|
6241
|
-
node = new mathMLTree.MathNode("mrow", [
|
|
6242
|
-
padding(),
|
|
6243
|
-
buildGroup$1(group.body, style),
|
|
6244
|
-
padding()
|
|
6245
|
-
]);
|
|
6246
|
-
} else {
|
|
6247
|
-
node = new mathMLTree.MathNode("menclose", [buildGroup$1(group.body, style)]);
|
|
6248
|
-
}
|
|
6211
|
+
const tag = group.label === "\\boxed" ? "mrow" : "menclose";
|
|
6212
|
+
const node = new MathNode(tag, [buildGroup$1(group.body, style)]);
|
|
6249
6213
|
switch (group.label) {
|
|
6250
6214
|
case "\\overline":
|
|
6251
6215
|
node.setAttribute("notation", "top"); // for Firefox & WebKit
|
|
@@ -6257,15 +6221,15 @@ var temml = (function () {
|
|
|
6257
6221
|
break
|
|
6258
6222
|
case "\\cancel":
|
|
6259
6223
|
node.setAttribute("notation", "updiagonalstrike");
|
|
6260
|
-
node.children.push(new
|
|
6224
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "upstrike"]));
|
|
6261
6225
|
break
|
|
6262
6226
|
case "\\bcancel":
|
|
6263
6227
|
node.setAttribute("notation", "downdiagonalstrike");
|
|
6264
|
-
node.children.push(new
|
|
6228
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "downstrike"]));
|
|
6265
6229
|
break
|
|
6266
6230
|
case "\\sout":
|
|
6267
6231
|
node.setAttribute("notation", "horizontalstrike");
|
|
6268
|
-
node.children.push(new
|
|
6232
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "sout"]));
|
|
6269
6233
|
break
|
|
6270
6234
|
case "\\xcancel":
|
|
6271
6235
|
node.setAttribute("notation", "updiagonalstrike downdiagonalstrike");
|
|
@@ -6274,17 +6238,17 @@ var temml = (function () {
|
|
|
6274
6238
|
case "\\longdiv":
|
|
6275
6239
|
node.setAttribute("notation", "longdiv");
|
|
6276
6240
|
node.classes.push("longdiv-top");
|
|
6277
|
-
node.children.push(new
|
|
6241
|
+
node.children.push(new MathNode("mrow", [], ["longdiv-arc"]));
|
|
6278
6242
|
break
|
|
6279
6243
|
case "\\phase":
|
|
6280
6244
|
node.setAttribute("notation", "phasorangle");
|
|
6281
6245
|
node.classes.push("phasor-bottom");
|
|
6282
|
-
node.children.push(new
|
|
6246
|
+
node.children.push(new MathNode("mrow", [], ["phasor-angle"]));
|
|
6283
6247
|
break
|
|
6284
6248
|
case "\\textcircled":
|
|
6285
6249
|
node.setAttribute("notation", "circle");
|
|
6286
6250
|
node.classes.push("circle-pad");
|
|
6287
|
-
node.children.push(new
|
|
6251
|
+
node.children.push(new MathNode("mrow", [], ["textcircle"]));
|
|
6288
6252
|
break
|
|
6289
6253
|
case "\\angl":
|
|
6290
6254
|
node.setAttribute("notation", "actuarial");
|
|
@@ -6292,8 +6256,7 @@ var temml = (function () {
|
|
|
6292
6256
|
break
|
|
6293
6257
|
case "\\boxed":
|
|
6294
6258
|
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
|
|
6295
|
-
node.
|
|
6296
|
-
node.style.padding = "padding: 3pt 0 3pt 0";
|
|
6259
|
+
node.style.padding = "3pt";
|
|
6297
6260
|
node.style.border = "1px solid";
|
|
6298
6261
|
node.setAttribute("scriptlevel", "0");
|
|
6299
6262
|
node.setAttribute("displaystyle", "true");
|
|
@@ -6310,12 +6273,10 @@ var temml = (function () {
|
|
|
6310
6273
|
//const fboxsep = 3; // 3 pt from LaTeX source2e
|
|
6311
6274
|
//node.setAttribute("height", `+${2 * fboxsep}pt`)
|
|
6312
6275
|
//node.setAttribute("voffset", `${fboxsep}pt`)
|
|
6313
|
-
|
|
6314
|
-
|
|
6276
|
+
node.style.padding = "3pt";
|
|
6315
6277
|
if (group.label === "\\fcolorbox") {
|
|
6316
|
-
style.border = "0.0667em solid " + String(group.borderColor);
|
|
6278
|
+
node.style.border = "0.0667em solid " + String(group.borderColor);
|
|
6317
6279
|
}
|
|
6318
|
-
node.style = style;
|
|
6319
6280
|
break
|
|
6320
6281
|
}
|
|
6321
6282
|
}
|
|
@@ -6538,7 +6499,7 @@ var temml = (function () {
|
|
|
6538
6499
|
};
|
|
6539
6500
|
},
|
|
6540
6501
|
mathmlBuilder(group, style) {
|
|
6541
|
-
return new
|
|
6502
|
+
return new MathNode("mrow");
|
|
6542
6503
|
}
|
|
6543
6504
|
});
|
|
6544
6505
|
|
|
@@ -6555,7 +6516,7 @@ var temml = (function () {
|
|
|
6555
6516
|
};
|
|
6556
6517
|
},
|
|
6557
6518
|
mathmlBuilder(group, style) {
|
|
6558
|
-
return new
|
|
6519
|
+
return new MathNode("mrow");
|
|
6559
6520
|
}
|
|
6560
6521
|
});
|
|
6561
6522
|
|
|
@@ -6598,7 +6559,7 @@ var temml = (function () {
|
|
|
6598
6559
|
: mathGroup.children[i].children[0].text;
|
|
6599
6560
|
}
|
|
6600
6561
|
// Wrap in a <mpadded> to prevent the same Firefox bug.
|
|
6601
|
-
const mpadded = new
|
|
6562
|
+
const mpadded = new MathNode("mpadded", [mi]);
|
|
6602
6563
|
mpadded.setAttribute("lspace", "0");
|
|
6603
6564
|
return mpadded
|
|
6604
6565
|
}
|
|
@@ -6624,8 +6585,8 @@ var temml = (function () {
|
|
|
6624
6585
|
// Ref: https://bugs.webkit.org/show_bug.cgi?id=129097
|
|
6625
6586
|
// We insert a text node that contains a zero-width space and wrap in an mrow.
|
|
6626
6587
|
// TODO: Get rid of this <mi> workaround when the Firefox bug is fixed.
|
|
6627
|
-
const bogus = new
|
|
6628
|
-
return new
|
|
6588
|
+
const bogus = new MathNode("mtext", new TextNode("\u200b"));
|
|
6589
|
+
return new MathNode("mrow", [bogus, mi])
|
|
6629
6590
|
}
|
|
6630
6591
|
return mi
|
|
6631
6592
|
};
|
|
@@ -6736,7 +6697,7 @@ var temml = (function () {
|
|
|
6736
6697
|
denom.setAttribute("scriptlevel", "2");
|
|
6737
6698
|
}
|
|
6738
6699
|
|
|
6739
|
-
let node = new
|
|
6700
|
+
let node = new MathNode("mfrac", [numer, denom]);
|
|
6740
6701
|
|
|
6741
6702
|
if (!group.hasBarLine) {
|
|
6742
6703
|
node.setAttribute("linethickness", "0px");
|
|
@@ -6749,8 +6710,8 @@ var temml = (function () {
|
|
|
6749
6710
|
const withDelims = [];
|
|
6750
6711
|
|
|
6751
6712
|
if (group.leftDelim != null) {
|
|
6752
|
-
const leftOp = new
|
|
6753
|
-
new
|
|
6713
|
+
const leftOp = new MathNode("mo", [
|
|
6714
|
+
new TextNode(group.leftDelim.replace("\\", ""))
|
|
6754
6715
|
]);
|
|
6755
6716
|
leftOp.setAttribute("fence", "true");
|
|
6756
6717
|
withDelims.push(leftOp);
|
|
@@ -6759,8 +6720,8 @@ var temml = (function () {
|
|
|
6759
6720
|
withDelims.push(node);
|
|
6760
6721
|
|
|
6761
6722
|
if (group.rightDelim != null) {
|
|
6762
|
-
const rightOp = new
|
|
6763
|
-
new
|
|
6723
|
+
const rightOp = new MathNode("mo", [
|
|
6724
|
+
new TextNode(group.rightDelim.replace("\\", ""))
|
|
6764
6725
|
]);
|
|
6765
6726
|
rightOp.setAttribute("fence", "true");
|
|
6766
6727
|
withDelims.push(rightOp);
|
|
@@ -6770,7 +6731,7 @@ var temml = (function () {
|
|
|
6770
6731
|
}
|
|
6771
6732
|
|
|
6772
6733
|
if (group.scriptLevel !== "auto") {
|
|
6773
|
-
node = new
|
|
6734
|
+
node = new MathNode("mstyle", [node]);
|
|
6774
6735
|
node.setAttribute("displaystyle", String(group.scriptLevel === "display"));
|
|
6775
6736
|
node.setAttribute("scriptlevel", scriptLevel[group.scriptLevel]);
|
|
6776
6737
|
}
|
|
@@ -7073,9 +7034,9 @@ var temml = (function () {
|
|
|
7073
7034
|
});
|
|
7074
7035
|
|
|
7075
7036
|
const mathmlBuilder$4 = (group, style) => {
|
|
7076
|
-
const accentNode =
|
|
7037
|
+
const accentNode = mathMLnode(group.label);
|
|
7077
7038
|
accentNode.style["math-depth"] = 0;
|
|
7078
|
-
return new
|
|
7039
|
+
return new MathNode(group.isOver ? "mover" : "munder", [
|
|
7079
7040
|
buildGroup$1(group.base, style),
|
|
7080
7041
|
accentNode
|
|
7081
7042
|
]);
|
|
@@ -7311,7 +7272,7 @@ var temml = (function () {
|
|
|
7311
7272
|
const node = new Img(group.src, group.alt, graphicStyle);
|
|
7312
7273
|
node.height = height;
|
|
7313
7274
|
node.depth = depth;
|
|
7314
|
-
return new
|
|
7275
|
+
return new MathNode("mtext", [node])
|
|
7315
7276
|
}
|
|
7316
7277
|
});
|
|
7317
7278
|
|
|
@@ -7361,17 +7322,17 @@ var temml = (function () {
|
|
|
7361
7322
|
? spaceCharacter(dimension.number)
|
|
7362
7323
|
: "";
|
|
7363
7324
|
if (group.mode === "text" && ch.length > 0) {
|
|
7364
|
-
const character = new
|
|
7365
|
-
return new
|
|
7325
|
+
const character = new TextNode(ch);
|
|
7326
|
+
return new MathNode("mtext", [character]);
|
|
7366
7327
|
} else {
|
|
7367
7328
|
if (dimension.number >= 0) {
|
|
7368
|
-
const node = new
|
|
7329
|
+
const node = new MathNode("mspace");
|
|
7369
7330
|
node.setAttribute("width", dimension.number + dimension.unit);
|
|
7370
7331
|
return node
|
|
7371
7332
|
} else {
|
|
7372
7333
|
// Don't use <mspace> or <mpadded> because
|
|
7373
7334
|
// WebKit recognizes negative left margin only on a <mrow> element
|
|
7374
|
-
const node = new
|
|
7335
|
+
const node = new MathNode("mrow");
|
|
7375
7336
|
node.style.marginLeft = dimension.number + dimension.unit;
|
|
7376
7337
|
return node
|
|
7377
7338
|
}
|
|
@@ -7412,7 +7373,7 @@ var temml = (function () {
|
|
|
7412
7373
|
},
|
|
7413
7374
|
mathmlBuilder(group, style) {
|
|
7414
7375
|
// Return a no-width, no-ink element with an HTML id.
|
|
7415
|
-
const node = new
|
|
7376
|
+
const node = new MathNode("mrow", [], ["tml-label"]);
|
|
7416
7377
|
if (group.string.length > 0) {
|
|
7417
7378
|
node.setLabel(group.string);
|
|
7418
7379
|
}
|
|
@@ -7456,8 +7417,8 @@ var temml = (function () {
|
|
|
7456
7417
|
// We need an invisible strut with the same depth as the group.
|
|
7457
7418
|
// We can't just read the depth, so we use \vphantom methods.
|
|
7458
7419
|
const phantomInner = buildExpression(ordargument(group.body), style);
|
|
7459
|
-
const phantom = new
|
|
7460
|
-
strut = new
|
|
7420
|
+
const phantom = new MathNode("mphantom", phantomInner);
|
|
7421
|
+
strut = new MathNode("mpadded", [phantom]);
|
|
7461
7422
|
strut.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
7462
7423
|
}
|
|
7463
7424
|
|
|
@@ -7467,9 +7428,9 @@ var temml = (function () {
|
|
|
7467
7428
|
inner.style.position = "absolute";
|
|
7468
7429
|
inner.style.right = "0";
|
|
7469
7430
|
inner.style.bottom = `0`; // If we could have read the ink depth, it would go here.
|
|
7470
|
-
node = new
|
|
7431
|
+
node = new MathNode("mpadded", [strut, inner]);
|
|
7471
7432
|
} else {
|
|
7472
|
-
node = new
|
|
7433
|
+
node = new MathNode("mpadded", [inner]);
|
|
7473
7434
|
}
|
|
7474
7435
|
|
|
7475
7436
|
if (group.alignment === "rlap") {
|
|
@@ -7575,7 +7536,7 @@ var temml = (function () {
|
|
|
7575
7536
|
const inner = buildExpression(group.body, style);
|
|
7576
7537
|
|
|
7577
7538
|
if (group.mclass === "minner") {
|
|
7578
|
-
node = new
|
|
7539
|
+
node = new MathNode("mpadded", inner);
|
|
7579
7540
|
} else if (group.mclass === "mord") {
|
|
7580
7541
|
if (group.isCharacterBox || inner[0].type === "mathord") {
|
|
7581
7542
|
node = inner[0];
|
|
@@ -7584,10 +7545,10 @@ var temml = (function () {
|
|
|
7584
7545
|
node.setAttribute("mathvariant", "normal");
|
|
7585
7546
|
}
|
|
7586
7547
|
} else {
|
|
7587
|
-
node = new
|
|
7548
|
+
node = new MathNode("mi", inner);
|
|
7588
7549
|
}
|
|
7589
7550
|
} else {
|
|
7590
|
-
node = new
|
|
7551
|
+
node = new MathNode("mrow", inner);
|
|
7591
7552
|
if (group.mustPromote) {
|
|
7592
7553
|
node = inner[0];
|
|
7593
7554
|
node.type = "mo";
|
|
@@ -7595,7 +7556,7 @@ var temml = (function () {
|
|
|
7595
7556
|
node.setAttribute("mathvariant", "italic");
|
|
7596
7557
|
}
|
|
7597
7558
|
} else {
|
|
7598
|
-
node = new
|
|
7559
|
+
node = new MathNode("mrow", inner);
|
|
7599
7560
|
}
|
|
7600
7561
|
|
|
7601
7562
|
// Set spacing based on what is the most likely adjacent atom type.
|
|
@@ -7605,17 +7566,17 @@ var temml = (function () {
|
|
|
7605
7566
|
if (doSpacing ) {
|
|
7606
7567
|
if (group.mclass === "mbin") {
|
|
7607
7568
|
// medium space
|
|
7608
|
-
node.children.unshift(padding
|
|
7609
|
-
node.children.push(padding
|
|
7569
|
+
node.children.unshift(padding(0.2222));
|
|
7570
|
+
node.children.push(padding(0.2222));
|
|
7610
7571
|
} else if (group.mclass === "mrel") {
|
|
7611
7572
|
// thickspace
|
|
7612
|
-
node.children.unshift(padding
|
|
7613
|
-
node.children.push(padding
|
|
7573
|
+
node.children.unshift(padding(0.2778));
|
|
7574
|
+
node.children.push(padding(0.2778));
|
|
7614
7575
|
} else if (group.mclass === "mpunct") {
|
|
7615
|
-
node.children.push(padding
|
|
7576
|
+
node.children.push(padding(0.1667));
|
|
7616
7577
|
} else if (group.mclass === "minner") {
|
|
7617
|
-
node.children.unshift(padding
|
|
7618
|
-
node.children.push(padding
|
|
7578
|
+
node.children.unshift(padding(0.0556)); // 1 mu is the most likely option
|
|
7579
|
+
node.children.push(padding(0.0556));
|
|
7619
7580
|
}
|
|
7620
7581
|
}
|
|
7621
7582
|
} else {
|
|
@@ -7665,7 +7626,7 @@ var temml = (function () {
|
|
|
7665
7626
|
},
|
|
7666
7627
|
handler({ parser, funcName }, args) {
|
|
7667
7628
|
const body = args[0];
|
|
7668
|
-
const isCharacterBox =
|
|
7629
|
+
const isCharacterBox$1 = isCharacterBox(body);
|
|
7669
7630
|
// We should not wrap a <mo> around a <mi> or <mord>. That would be invalid MathML.
|
|
7670
7631
|
// In that case, we instead promote the text contents of the body to the parent.
|
|
7671
7632
|
let mustPromote = true;
|
|
@@ -7694,7 +7655,7 @@ var temml = (function () {
|
|
|
7694
7655
|
mode: parser.mode,
|
|
7695
7656
|
mclass: "m" + funcName.slice(5),
|
|
7696
7657
|
body: ordargument(mustPromote ? mord : body),
|
|
7697
|
-
isCharacterBox,
|
|
7658
|
+
isCharacterBox: isCharacterBox$1,
|
|
7698
7659
|
mustPromote
|
|
7699
7660
|
};
|
|
7700
7661
|
}
|
|
@@ -7731,7 +7692,7 @@ var temml = (function () {
|
|
|
7731
7692
|
mode: parser.mode,
|
|
7732
7693
|
mclass: binrelClass(args[0]),
|
|
7733
7694
|
body: ordargument(args[1]),
|
|
7734
|
-
isCharacterBox:
|
|
7695
|
+
isCharacterBox: isCharacterBox(args[1])
|
|
7735
7696
|
};
|
|
7736
7697
|
}
|
|
7737
7698
|
});
|
|
@@ -7845,8 +7806,8 @@ var temml = (function () {
|
|
|
7845
7806
|
mathmlBuilder(group, style) {
|
|
7846
7807
|
const base = buildGroup$1(group.base, style);
|
|
7847
7808
|
|
|
7848
|
-
const prescriptsNode = new
|
|
7849
|
-
const noneNode = new
|
|
7809
|
+
const prescriptsNode = new MathNode("mprescripts");
|
|
7810
|
+
const noneNode = new MathNode("none");
|
|
7850
7811
|
let children = [];
|
|
7851
7812
|
|
|
7852
7813
|
const preSub = buildGroup(group.prescripts.sub, style, noneNode);
|
|
@@ -7865,7 +7826,7 @@ var temml = (function () {
|
|
|
7865
7826
|
children = [base, prescriptsNode, preSub, preSup];
|
|
7866
7827
|
}
|
|
7867
7828
|
|
|
7868
|
-
return new
|
|
7829
|
+
return new MathNode("mmultiscripts", children);
|
|
7869
7830
|
}
|
|
7870
7831
|
});
|
|
7871
7832
|
|
|
@@ -7878,9 +7839,9 @@ var temml = (function () {
|
|
|
7878
7839
|
allowedInText: false
|
|
7879
7840
|
},
|
|
7880
7841
|
handler({ parser }, args) {
|
|
7881
|
-
const isCharacterBox =
|
|
7842
|
+
const isCharacterBox$1 = isCharacterBox(args[0]);
|
|
7882
7843
|
let body;
|
|
7883
|
-
if (isCharacterBox) {
|
|
7844
|
+
if (isCharacterBox$1) {
|
|
7884
7845
|
body = ordargument(args[0]);
|
|
7885
7846
|
if (body[0].text.charAt(0) === "\\") {
|
|
7886
7847
|
body[0].text = symbols.math[body[0].text].replace;
|
|
@@ -7898,7 +7859,7 @@ var temml = (function () {
|
|
|
7898
7859
|
type: "not",
|
|
7899
7860
|
mode: parser.mode,
|
|
7900
7861
|
body,
|
|
7901
|
-
isCharacterBox
|
|
7862
|
+
isCharacterBox: isCharacterBox$1
|
|
7902
7863
|
};
|
|
7903
7864
|
},
|
|
7904
7865
|
mathmlBuilder(group, style) {
|
|
@@ -8277,9 +8238,9 @@ var temml = (function () {
|
|
|
8277
8238
|
let isAllString = true; // default
|
|
8278
8239
|
for (let i = 0; i < expression.length; i++) {
|
|
8279
8240
|
let node = expression[i];
|
|
8280
|
-
if (node instanceof
|
|
8241
|
+
if (node instanceof MathNode) {
|
|
8281
8242
|
if ((node.type === "mrow" || node.type === "mpadded") && node.children.length === 1 &&
|
|
8282
|
-
node.children[0] instanceof
|
|
8243
|
+
node.children[0] instanceof MathNode) {
|
|
8283
8244
|
node = node.children[0];
|
|
8284
8245
|
}
|
|
8285
8246
|
switch (node.type) {
|
|
@@ -8296,14 +8257,14 @@ var temml = (function () {
|
|
|
8296
8257
|
if (ch === "") {
|
|
8297
8258
|
isAllString = false;
|
|
8298
8259
|
} else {
|
|
8299
|
-
expression[i] = new
|
|
8260
|
+
expression[i] = new MathNode("mtext", [new TextNode(ch)]);
|
|
8300
8261
|
}
|
|
8301
8262
|
}
|
|
8302
8263
|
}
|
|
8303
8264
|
break
|
|
8304
8265
|
case "mo": {
|
|
8305
8266
|
const child = node.children[0];
|
|
8306
|
-
if (node.children.length === 1 && child instanceof
|
|
8267
|
+
if (node.children.length === 1 && child instanceof TextNode) {
|
|
8307
8268
|
child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
|
|
8308
8269
|
} else {
|
|
8309
8270
|
isAllString = false;
|
|
@@ -8321,7 +8282,7 @@ var temml = (function () {
|
|
|
8321
8282
|
if (isAllString) {
|
|
8322
8283
|
// Write a single TextNode instead of multiple nested tags.
|
|
8323
8284
|
const word = expression.map((node) => node.toText()).join("");
|
|
8324
|
-
expression = [new
|
|
8285
|
+
expression = [new TextNode(word)];
|
|
8325
8286
|
} else if (
|
|
8326
8287
|
expression.length === 1
|
|
8327
8288
|
&& ["mover", "munder"].includes(expression[0].type) &&
|
|
@@ -8329,41 +8290,41 @@ var temml = (function () {
|
|
|
8329
8290
|
) {
|
|
8330
8291
|
expression[0].children[0].type = "mi";
|
|
8331
8292
|
if (group.parentIsSupSub) {
|
|
8332
|
-
return new
|
|
8293
|
+
return new MathNode("mrow", expression)
|
|
8333
8294
|
} else {
|
|
8334
|
-
const operator = new
|
|
8335
|
-
return
|
|
8295
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
8296
|
+
return newDocumentFragment([expression[0], operator])
|
|
8336
8297
|
}
|
|
8337
8298
|
}
|
|
8338
8299
|
|
|
8339
8300
|
let wrapper;
|
|
8340
8301
|
if (isAllString) {
|
|
8341
|
-
wrapper = new
|
|
8302
|
+
wrapper = new MathNode("mi", expression);
|
|
8342
8303
|
if (expression[0].text.length === 1) {
|
|
8343
8304
|
wrapper.setAttribute("mathvariant", "normal");
|
|
8344
8305
|
}
|
|
8345
8306
|
} else {
|
|
8346
|
-
wrapper = new
|
|
8307
|
+
wrapper = new MathNode("mrow", expression);
|
|
8347
8308
|
}
|
|
8348
8309
|
|
|
8349
8310
|
if (!group.parentIsSupSub) {
|
|
8350
8311
|
// Append an <mo>⁡</mo>.
|
|
8351
8312
|
// ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
|
|
8352
|
-
const operator = new
|
|
8313
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
8353
8314
|
const fragment = [wrapper, operator];
|
|
8354
8315
|
if (group.needsLeadingSpace) {
|
|
8355
8316
|
// LaTeX gives operator spacing, but a <mi> gets ord spacing.
|
|
8356
8317
|
// So add a leading space.
|
|
8357
|
-
const space = new
|
|
8318
|
+
const space = new MathNode("mspace");
|
|
8358
8319
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
8359
8320
|
fragment.unshift(space);
|
|
8360
8321
|
}
|
|
8361
8322
|
if (!group.isFollowedByDelimiter) {
|
|
8362
|
-
const trail = new
|
|
8323
|
+
const trail = new MathNode("mspace");
|
|
8363
8324
|
trail.setAttribute("width", "0.1667em"); // thin space.
|
|
8364
8325
|
fragment.push(trail);
|
|
8365
8326
|
}
|
|
8366
|
-
return
|
|
8327
|
+
return newDocumentFragment(fragment)
|
|
8367
8328
|
}
|
|
8368
8329
|
|
|
8369
8330
|
return wrapper
|
|
@@ -8423,7 +8384,7 @@ var temml = (function () {
|
|
|
8423
8384
|
},
|
|
8424
8385
|
mathmlBuilder: (group, style) => {
|
|
8425
8386
|
const inner = buildExpression(group.body, style);
|
|
8426
|
-
return new
|
|
8387
|
+
return new MathNode("mphantom", inner);
|
|
8427
8388
|
}
|
|
8428
8389
|
});
|
|
8429
8390
|
|
|
@@ -8444,8 +8405,8 @@ var temml = (function () {
|
|
|
8444
8405
|
},
|
|
8445
8406
|
mathmlBuilder: (group, style) => {
|
|
8446
8407
|
const inner = buildExpression(ordargument(group.body), style);
|
|
8447
|
-
const phantom = new
|
|
8448
|
-
const node = new
|
|
8408
|
+
const phantom = new MathNode("mphantom", inner);
|
|
8409
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
8449
8410
|
node.setAttribute("height", "0px");
|
|
8450
8411
|
node.setAttribute("depth", "0px");
|
|
8451
8412
|
return node;
|
|
@@ -8469,8 +8430,8 @@ var temml = (function () {
|
|
|
8469
8430
|
},
|
|
8470
8431
|
mathmlBuilder: (group, style) => {
|
|
8471
8432
|
const inner = buildExpression(ordargument(group.body), style);
|
|
8472
|
-
const phantom = new
|
|
8473
|
-
const node = new
|
|
8433
|
+
const phantom = new MathNode("mphantom", inner);
|
|
8434
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
8474
8435
|
node.setAttribute("width", "0px");
|
|
8475
8436
|
return node;
|
|
8476
8437
|
}
|
|
@@ -8507,7 +8468,7 @@ var temml = (function () {
|
|
|
8507
8468
|
|
|
8508
8469
|
const mathmlBuilder = (group, style) => {
|
|
8509
8470
|
const newStyle = style.withLevel(StyleLevel.TEXT);
|
|
8510
|
-
const node = new
|
|
8471
|
+
const node = new MathNode("mpadded", [buildGroup$1(group.body, newStyle)]);
|
|
8511
8472
|
const dy = calculateSize(group.dy, style);
|
|
8512
8473
|
node.setAttribute("voffset", dy.number + dy.unit);
|
|
8513
8474
|
// Add padding, which acts to increase height in Chromium.
|
|
@@ -8655,7 +8616,7 @@ var temml = (function () {
|
|
|
8655
8616
|
: { number: 0, unit: "em" };
|
|
8656
8617
|
const color = (style.color && style.getColor()) || "black";
|
|
8657
8618
|
|
|
8658
|
-
const rule = new
|
|
8619
|
+
const rule = new MathNode("mspace");
|
|
8659
8620
|
if (width.number > 0 && height.number > 0) {
|
|
8660
8621
|
rule.setAttribute("mathbackground", color);
|
|
8661
8622
|
}
|
|
@@ -8663,7 +8624,7 @@ var temml = (function () {
|
|
|
8663
8624
|
rule.setAttribute("height", height.number + height.unit);
|
|
8664
8625
|
if (shift.number === 0) { return rule }
|
|
8665
8626
|
|
|
8666
|
-
const wrapper = new
|
|
8627
|
+
const wrapper = new MathNode("mpadded", [rule]);
|
|
8667
8628
|
if (shift.number >= 0) {
|
|
8668
8629
|
wrapper.setAttribute("height", "+" + shift.number + shift.unit);
|
|
8669
8630
|
} else {
|
|
@@ -8735,8 +8696,8 @@ var temml = (function () {
|
|
|
8735
8696
|
const numerator = group.numerator.split('').map(c => unicodeNumSups[c]).join('');
|
|
8736
8697
|
const denominator = group.denominator.split('').map(c => unicodeNumSubs[c]).join('');
|
|
8737
8698
|
// Use a fraction slash.
|
|
8738
|
-
const text = new
|
|
8739
|
-
return new
|
|
8699
|
+
const text = new TextNode(numerator + "\u2044" + denominator, group.mode, style);
|
|
8700
|
+
return new MathNode("mn", [text], ["special-fraction"])
|
|
8740
8701
|
}
|
|
8741
8702
|
});
|
|
8742
8703
|
|
|
@@ -8849,7 +8810,7 @@ var temml = (function () {
|
|
|
8849
8810
|
};
|
|
8850
8811
|
},
|
|
8851
8812
|
mathmlBuilder: (group, style) => {
|
|
8852
|
-
const node = new
|
|
8813
|
+
const node = new MathNode("mpadded", [buildGroup$1(group.body, style)]);
|
|
8853
8814
|
|
|
8854
8815
|
if (group.smashHeight) {
|
|
8855
8816
|
node.setAttribute("height", "0px");
|
|
@@ -8902,11 +8863,11 @@ var temml = (function () {
|
|
|
8902
8863
|
mathmlBuilder(group, style) {
|
|
8903
8864
|
const { body, index } = group;
|
|
8904
8865
|
return index
|
|
8905
|
-
? new
|
|
8866
|
+
? new MathNode("mroot", [
|
|
8906
8867
|
buildGroup$1(body, style),
|
|
8907
8868
|
buildGroup$1(index, style.incrementLevel())
|
|
8908
8869
|
])
|
|
8909
|
-
: new
|
|
8870
|
+
: new MathNode("msqrt", [buildGroup$1(body, style)]);
|
|
8910
8871
|
}
|
|
8911
8872
|
});
|
|
8912
8873
|
|
|
@@ -9105,26 +9066,26 @@ var temml = (function () {
|
|
|
9105
9066
|
}
|
|
9106
9067
|
}
|
|
9107
9068
|
|
|
9108
|
-
let node = new
|
|
9069
|
+
let node = new MathNode(nodeType, children);
|
|
9109
9070
|
if (appendApplyFunction) {
|
|
9110
9071
|
// Append an <mo>⁡</mo>.
|
|
9111
9072
|
// ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
|
|
9112
|
-
const operator = new
|
|
9073
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
9113
9074
|
if (needsLeadingSpace) {
|
|
9114
|
-
const space = new
|
|
9075
|
+
const space = new MathNode("mspace");
|
|
9115
9076
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
9116
|
-
node =
|
|
9077
|
+
node = newDocumentFragment([space, node, operator]);
|
|
9117
9078
|
} else {
|
|
9118
|
-
node =
|
|
9079
|
+
node = newDocumentFragment([node, operator]);
|
|
9119
9080
|
}
|
|
9120
9081
|
if (appendSpace) {
|
|
9121
|
-
const space = new
|
|
9082
|
+
const space = new MathNode("mspace");
|
|
9122
9083
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
9123
9084
|
node.children.push(space);
|
|
9124
9085
|
}
|
|
9125
9086
|
} else if (symbolRegEx.test(nodeType)) {
|
|
9126
9087
|
// Wrap in a <mrow>. Otherwise Firefox stretchy parens will not stretch to include limits.
|
|
9127
|
-
node = new
|
|
9088
|
+
node = new MathNode("mrow", [node]);
|
|
9128
9089
|
}
|
|
9129
9090
|
|
|
9130
9091
|
return node
|
|
@@ -9149,7 +9110,7 @@ var temml = (function () {
|
|
|
9149
9110
|
defineFunctionBuilders({
|
|
9150
9111
|
type: "atom",
|
|
9151
9112
|
mathmlBuilder(group, style) {
|
|
9152
|
-
const node = new
|
|
9113
|
+
const node = new MathNode("mo", [makeText(group.text, group.mode)]);
|
|
9153
9114
|
if (group.family === "punct") {
|
|
9154
9115
|
node.setAttribute("separator", "true");
|
|
9155
9116
|
} else if (group.family === "open" || group.family === "close") {
|
|
@@ -9179,10 +9140,10 @@ var temml = (function () {
|
|
|
9179
9140
|
} else if (group.needsSpacing) {
|
|
9180
9141
|
// Fix a MathML bug that occurs when a <mo> is between two <mtext> elements.
|
|
9181
9142
|
if (group.family === "bin") {
|
|
9182
|
-
return new
|
|
9143
|
+
return new MathNode("mrow", [padding(0.222), node, padding(0.222)])
|
|
9183
9144
|
} else {
|
|
9184
9145
|
// REL spacing
|
|
9185
|
-
return new
|
|
9146
|
+
return new MathNode("mrow", [padding(0.2778), node, padding(0.2778)])
|
|
9186
9147
|
}
|
|
9187
9148
|
}
|
|
9188
9149
|
return node;
|
|
@@ -9523,8 +9484,8 @@ var temml = (function () {
|
|
|
9523
9484
|
"\\backprime", "\\backdprime", "\\backtrprime"]);
|
|
9524
9485
|
|
|
9525
9486
|
const italicNumber = (text, variant, tag) => {
|
|
9526
|
-
const mn = new
|
|
9527
|
-
const wrapper = new
|
|
9487
|
+
const mn = new MathNode(tag, [text]);
|
|
9488
|
+
const wrapper = new MathNode("mstyle", [mn]);
|
|
9528
9489
|
wrapper.style["font-style"] = "italic";
|
|
9529
9490
|
wrapper.style["font-family"] = "Cambria, 'Times New Roman', serif";
|
|
9530
9491
|
if (variant === "bold-italic") { wrapper.style["font-weight"] = "bold"; }
|
|
@@ -9541,17 +9502,17 @@ var temml = (function () {
|
|
|
9541
9502
|
const variant = getVariant(group, style) || defaultVariant;
|
|
9542
9503
|
if (variant === "script") {
|
|
9543
9504
|
text.text = variantChar(text.text, variant);
|
|
9544
|
-
return new
|
|
9505
|
+
return new MathNode("mi", [text], [style.font])
|
|
9545
9506
|
} else if (variant !== "italic") {
|
|
9546
9507
|
text.text = variantChar(text.text, variant);
|
|
9547
9508
|
}
|
|
9548
|
-
let node = new
|
|
9509
|
+
let node = new MathNode("mi", [text]);
|
|
9549
9510
|
// TODO: Handle U+1D49C - U+1D4CF per https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
9550
9511
|
if (variant === "normal") {
|
|
9551
9512
|
node.setAttribute("mathvariant", "normal");
|
|
9552
9513
|
if (text.text.length === 1) {
|
|
9553
9514
|
// A Firefox bug will apply spacing here, but there should be none. Fix it.
|
|
9554
|
-
node = new
|
|
9515
|
+
node = new MathNode("mpadded", [node]);
|
|
9555
9516
|
node.setAttribute("lspace", "0");
|
|
9556
9517
|
}
|
|
9557
9518
|
}
|
|
@@ -9582,15 +9543,15 @@ var temml = (function () {
|
|
|
9582
9543
|
if (variant !== "normal") {
|
|
9583
9544
|
text.text = text.text.split("").map(c => variantChar(c, variant)).join("");
|
|
9584
9545
|
}
|
|
9585
|
-
node = new
|
|
9546
|
+
node = new MathNode(tag, [text]);
|
|
9586
9547
|
}
|
|
9587
9548
|
} else if (group.mode === "text") {
|
|
9588
9549
|
if (variant !== "normal") {
|
|
9589
9550
|
text.text = variantChar(text.text, variant);
|
|
9590
9551
|
}
|
|
9591
|
-
node = new
|
|
9552
|
+
node = new MathNode("mtext", [text]);
|
|
9592
9553
|
} else if (primes.has(group.text)) {
|
|
9593
|
-
node = new
|
|
9554
|
+
node = new MathNode("mo", [text]);
|
|
9594
9555
|
// TODO: If/when Chromium uses ssty variant for prime, remove the next line.
|
|
9595
9556
|
node.classes.push("tml-prime");
|
|
9596
9557
|
} else {
|
|
@@ -9598,7 +9559,7 @@ var temml = (function () {
|
|
|
9598
9559
|
if (variant !== "italic") {
|
|
9599
9560
|
text.text = variantChar(text.text, variant);
|
|
9600
9561
|
}
|
|
9601
|
-
node = new
|
|
9562
|
+
node = new MathNode("mi", [text]);
|
|
9602
9563
|
if (text.text === origText && latinRegEx.test(origText)) {
|
|
9603
9564
|
node.setAttribute("mathvariant", "italic");
|
|
9604
9565
|
}
|
|
@@ -9641,11 +9602,11 @@ var temml = (function () {
|
|
|
9641
9602
|
// Firefox does not render a space in a <mtext> </mtext>. So write a no-break space.
|
|
9642
9603
|
// TODO: If Firefox fixes that bug, uncomment the next line and write ch into the node.
|
|
9643
9604
|
//const ch = (regularSpace[group.text].className === "nobreak") ? "\u00a0" : " "
|
|
9644
|
-
node = new
|
|
9605
|
+
node = new MathNode("mtext", [new TextNode("\u00a0")]);
|
|
9645
9606
|
} else if (Object.prototype.hasOwnProperty.call(cssSpace, group.text)) {
|
|
9646
9607
|
// MathML 3.0 calls for nobreak to occur in an <mo>, not an <mtext>
|
|
9647
9608
|
// Ref: https://www.w3.org/Math/draft-spec/mathml.html#chapter3_presm.lbattrs
|
|
9648
|
-
node = new
|
|
9609
|
+
node = new MathNode("mo");
|
|
9649
9610
|
if (group.text === "\\nobreak") {
|
|
9650
9611
|
node.setAttribute("linebreak", "nobreak");
|
|
9651
9612
|
}
|
|
@@ -9760,10 +9721,10 @@ var temml = (function () {
|
|
|
9760
9721
|
},
|
|
9761
9722
|
mathmlBuilder(group, style) {
|
|
9762
9723
|
// Use a math table to create vertically centered content.
|
|
9763
|
-
const mtd = new
|
|
9724
|
+
const mtd = new MathNode("mtd", [buildGroup$1(group.body, style)]);
|
|
9764
9725
|
mtd.style.padding = "0";
|
|
9765
|
-
const mtr = new
|
|
9766
|
-
return new
|
|
9726
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
9727
|
+
return new MathNode("mtable", [mtr])
|
|
9767
9728
|
}
|
|
9768
9729
|
});
|
|
9769
9730
|
|
|
@@ -9782,8 +9743,8 @@ var temml = (function () {
|
|
|
9782
9743
|
throw new ParseError("\\verb ended by end of line instead of matching delimiter");
|
|
9783
9744
|
},
|
|
9784
9745
|
mathmlBuilder(group, style) {
|
|
9785
|
-
const text = new
|
|
9786
|
-
const node = new
|
|
9746
|
+
const text = new TextNode(makeVerb(group));
|
|
9747
|
+
const node = new MathNode("mtext", [text]);
|
|
9787
9748
|
node.setAttribute("mathvariant", "monospace");
|
|
9788
9749
|
return node;
|
|
9789
9750
|
}
|
|
@@ -12115,7 +12076,7 @@ var temml = (function () {
|
|
|
12115
12076
|
* https://mit-license.org/
|
|
12116
12077
|
*/
|
|
12117
12078
|
|
|
12118
|
-
const version = "0.
|
|
12079
|
+
const version = "0.12.01";
|
|
12119
12080
|
|
|
12120
12081
|
function postProcess(block) {
|
|
12121
12082
|
const labelMap = {};
|