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.cjs
CHANGED
|
@@ -181,16 +181,6 @@ const round = function(n) {
|
|
|
181
181
|
return +n.toFixed(4);
|
|
182
182
|
};
|
|
183
183
|
|
|
184
|
-
var utils = {
|
|
185
|
-
deflt,
|
|
186
|
-
escape,
|
|
187
|
-
hyphenate,
|
|
188
|
-
getBaseElem,
|
|
189
|
-
isCharacterBox,
|
|
190
|
-
protocolFromUrl,
|
|
191
|
-
round
|
|
192
|
-
};
|
|
193
|
-
|
|
194
184
|
/**
|
|
195
185
|
* This is a module for storing settings passed into Temml. It correctly handles
|
|
196
186
|
* default settings.
|
|
@@ -204,24 +194,24 @@ class Settings {
|
|
|
204
194
|
constructor(options) {
|
|
205
195
|
// allow null options
|
|
206
196
|
options = options || {};
|
|
207
|
-
this.displayMode =
|
|
208
|
-
this.annotate =
|
|
209
|
-
this.leqno =
|
|
210
|
-
this.throwOnError =
|
|
211
|
-
this.errorColor =
|
|
197
|
+
this.displayMode = deflt(options.displayMode, false); // boolean
|
|
198
|
+
this.annotate = deflt(options.annotate, false); // boolean
|
|
199
|
+
this.leqno = deflt(options.leqno, false); // boolean
|
|
200
|
+
this.throwOnError = deflt(options.throwOnError, false); // boolean
|
|
201
|
+
this.errorColor = deflt(options.errorColor, "#b22222"); // string
|
|
212
202
|
this.macros = options.macros || {};
|
|
213
|
-
this.wrap =
|
|
214
|
-
this.xml =
|
|
215
|
-
this.colorIsTextColor =
|
|
216
|
-
this.strict =
|
|
217
|
-
this.trust =
|
|
203
|
+
this.wrap = deflt(options.wrap, "none"); // "none" | "tex" | "="
|
|
204
|
+
this.xml = deflt(options.xml, false); // boolean
|
|
205
|
+
this.colorIsTextColor = deflt(options.colorIsTextColor, false); // boolean
|
|
206
|
+
this.strict = deflt(options.strict, false); // boolean
|
|
207
|
+
this.trust = deflt(options.trust, false); // trust context. See html.js.
|
|
218
208
|
this.maxSize = (options.maxSize === undefined
|
|
219
209
|
? [Infinity, Infinity]
|
|
220
210
|
: Array.isArray(options.maxSize)
|
|
221
211
|
? options.maxSize
|
|
222
212
|
: [Infinity, Infinity]
|
|
223
213
|
);
|
|
224
|
-
this.maxExpand = Math.max(0,
|
|
214
|
+
this.maxExpand = Math.max(0, deflt(options.maxExpand, 1000)); // number
|
|
225
215
|
}
|
|
226
216
|
|
|
227
217
|
/**
|
|
@@ -234,7 +224,7 @@ class Settings {
|
|
|
234
224
|
*/
|
|
235
225
|
isTrusted(context) {
|
|
236
226
|
if (context.url && !context.protocol) {
|
|
237
|
-
const protocol =
|
|
227
|
+
const protocol = protocolFromUrl(context.url);
|
|
238
228
|
if (protocol == null) {
|
|
239
229
|
return false
|
|
240
230
|
}
|
|
@@ -430,7 +420,7 @@ const toMarkup = function(tagName) {
|
|
|
430
420
|
|
|
431
421
|
// Add the class
|
|
432
422
|
if (this.classes.length) {
|
|
433
|
-
markup += ` class="${
|
|
423
|
+
markup += ` class="${escape(createClass(this.classes))}"`;
|
|
434
424
|
}
|
|
435
425
|
|
|
436
426
|
let styles = "";
|
|
@@ -438,7 +428,7 @@ const toMarkup = function(tagName) {
|
|
|
438
428
|
// Add the styles, after hyphenation
|
|
439
429
|
for (const style in this.style) {
|
|
440
430
|
if (Object.prototype.hasOwnProperty.call(this.style, style )) {
|
|
441
|
-
styles += `${
|
|
431
|
+
styles += `${hyphenate(style)}:${this.style[style]};`;
|
|
442
432
|
}
|
|
443
433
|
}
|
|
444
434
|
|
|
@@ -449,7 +439,7 @@ const toMarkup = function(tagName) {
|
|
|
449
439
|
// Add the attributes
|
|
450
440
|
for (const attr in this.attributes) {
|
|
451
441
|
if (Object.prototype.hasOwnProperty.call(this.attributes, attr )) {
|
|
452
|
-
markup += ` ${attr}="${
|
|
442
|
+
markup += ` ${attr}="${escape(this.attributes[attr])}"`;
|
|
453
443
|
}
|
|
454
444
|
}
|
|
455
445
|
|
|
@@ -497,7 +487,7 @@ let TextNode$1 = class TextNode {
|
|
|
497
487
|
return document.createTextNode(this.text);
|
|
498
488
|
}
|
|
499
489
|
toMarkup() {
|
|
500
|
-
return
|
|
490
|
+
return escape(this.text);
|
|
501
491
|
}
|
|
502
492
|
};
|
|
503
493
|
|
|
@@ -522,9 +512,9 @@ class AnchorNode {
|
|
|
522
512
|
}
|
|
523
513
|
|
|
524
514
|
toMarkup() {
|
|
525
|
-
let markup = `<a href='${
|
|
515
|
+
let markup = `<a href='${escape(this.href)}'`;
|
|
526
516
|
if (this.classes.length > 0) {
|
|
527
|
-
markup += ` class="${
|
|
517
|
+
markup += ` class="${escape(createClass(this.classes))}"`;
|
|
528
518
|
}
|
|
529
519
|
markup += ">";
|
|
530
520
|
for (let i = 0; i < this.children.length; i++) {
|
|
@@ -573,11 +563,11 @@ class Img {
|
|
|
573
563
|
let styles = "";
|
|
574
564
|
for (const style in this.style) {
|
|
575
565
|
if (Object.prototype.hasOwnProperty.call(this.style, style )) {
|
|
576
|
-
styles += `${
|
|
566
|
+
styles += `${hyphenate(style)}:${this.style[style]};`;
|
|
577
567
|
}
|
|
578
568
|
}
|
|
579
569
|
if (styles) {
|
|
580
|
-
markup += ` style="${
|
|
570
|
+
markup += ` style="${escape(styles)}"`;
|
|
581
571
|
}
|
|
582
572
|
|
|
583
573
|
markup += ">";
|
|
@@ -671,13 +661,13 @@ class MathNode {
|
|
|
671
661
|
for (const attr in this.attributes) {
|
|
672
662
|
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
673
663
|
markup += " " + attr + '="';
|
|
674
|
-
markup +=
|
|
664
|
+
markup += escape(this.attributes[attr]);
|
|
675
665
|
markup += '"';
|
|
676
666
|
}
|
|
677
667
|
}
|
|
678
668
|
|
|
679
669
|
if (this.classes.length > 0) {
|
|
680
|
-
markup += ` class="${
|
|
670
|
+
markup += ` class="${escape(createClass(this.classes))}"`;
|
|
681
671
|
}
|
|
682
672
|
|
|
683
673
|
let styles = "";
|
|
@@ -685,7 +675,7 @@ class MathNode {
|
|
|
685
675
|
// Add the styles, after hyphenation
|
|
686
676
|
for (const style in this.style) {
|
|
687
677
|
if (Object.prototype.hasOwnProperty.call(this.style, style )) {
|
|
688
|
-
styles += `${
|
|
678
|
+
styles += `${hyphenate(style)}:${this.style[style]};`;
|
|
689
679
|
}
|
|
690
680
|
}
|
|
691
681
|
|
|
@@ -732,7 +722,7 @@ class TextNode {
|
|
|
732
722
|
* (representing the text itself).
|
|
733
723
|
*/
|
|
734
724
|
toMarkup() {
|
|
735
|
-
return
|
|
725
|
+
return escape(this.toText());
|
|
736
726
|
}
|
|
737
727
|
|
|
738
728
|
/**
|
|
@@ -757,12 +747,6 @@ const wrapWithMstyle = expression => {
|
|
|
757
747
|
return node
|
|
758
748
|
};
|
|
759
749
|
|
|
760
|
-
var mathMLTree = {
|
|
761
|
-
MathNode,
|
|
762
|
-
TextNode,
|
|
763
|
-
newDocumentFragment
|
|
764
|
-
};
|
|
765
|
-
|
|
766
750
|
/**
|
|
767
751
|
* This file provides support for building horizontal stretchy elements.
|
|
768
752
|
*/
|
|
@@ -854,8 +838,8 @@ const stretchyCodePoint = {
|
|
|
854
838
|
};
|
|
855
839
|
|
|
856
840
|
const mathMLnode = function(label) {
|
|
857
|
-
const child = new
|
|
858
|
-
const node = new
|
|
841
|
+
const child = new TextNode(stretchyCodePoint[label.slice(1)]);
|
|
842
|
+
const node = new MathNode("mo", [child]);
|
|
859
843
|
node.setAttribute("stretchy", "true");
|
|
860
844
|
return node
|
|
861
845
|
};
|
|
@@ -878,11 +862,6 @@ const accentNode = (group) => {
|
|
|
878
862
|
return mo
|
|
879
863
|
};
|
|
880
864
|
|
|
881
|
-
var stretchy = {
|
|
882
|
-
mathMLnode,
|
|
883
|
-
accentNode
|
|
884
|
-
};
|
|
885
|
-
|
|
886
865
|
/**
|
|
887
866
|
* This file holds a list of all no-argument functions and single-character
|
|
888
867
|
* symbols (like 'a' or ';').
|
|
@@ -2036,13 +2015,13 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
|
2036
2015
|
node.attributes.linebreak === "newline") {
|
|
2037
2016
|
// A hard line break. Create a <mtr> for the current block.
|
|
2038
2017
|
if (block.length > 0) {
|
|
2039
|
-
mrows.push(new
|
|
2018
|
+
mrows.push(new MathNode("mrow", block));
|
|
2040
2019
|
}
|
|
2041
2020
|
mrows.push(node);
|
|
2042
2021
|
block = [];
|
|
2043
|
-
const mtd = new
|
|
2022
|
+
const mtd = new MathNode("mtd", mrows);
|
|
2044
2023
|
mtd.style.textAlign = "left";
|
|
2045
|
-
mtrs.push(new
|
|
2024
|
+
mtrs.push(new MathNode("mtr", [mtd]));
|
|
2046
2025
|
mrows = [];
|
|
2047
2026
|
i += 1;
|
|
2048
2027
|
continue
|
|
@@ -2060,7 +2039,7 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
|
2060
2039
|
if (numTopLevelEquals > 1) {
|
|
2061
2040
|
block.pop();
|
|
2062
2041
|
// Start a new block. (Insert a soft linebreak.)
|
|
2063
|
-
const element = new
|
|
2042
|
+
const element = new MathNode("mrow", block);
|
|
2064
2043
|
mrows.push(element);
|
|
2065
2044
|
block = [node];
|
|
2066
2045
|
}
|
|
@@ -2101,7 +2080,7 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
|
2101
2080
|
}
|
|
2102
2081
|
if (glueIsFreeOfNobreak) {
|
|
2103
2082
|
// Start a new block. (Insert a soft linebreak.)
|
|
2104
|
-
const element = new
|
|
2083
|
+
const element = new MathNode("mrow", block);
|
|
2105
2084
|
mrows.push(element);
|
|
2106
2085
|
block = [];
|
|
2107
2086
|
}
|
|
@@ -2110,22 +2089,22 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
|
2110
2089
|
i += 1;
|
|
2111
2090
|
}
|
|
2112
2091
|
if (block.length > 0) {
|
|
2113
|
-
const element = new
|
|
2092
|
+
const element = new MathNode("mrow", block);
|
|
2114
2093
|
mrows.push(element);
|
|
2115
2094
|
}
|
|
2116
2095
|
if (mtrs.length > 0) {
|
|
2117
|
-
const mtd = new
|
|
2096
|
+
const mtd = new MathNode("mtd", mrows);
|
|
2118
2097
|
mtd.style.textAlign = "left";
|
|
2119
|
-
const mtr = new
|
|
2098
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
2120
2099
|
mtrs.push(mtr);
|
|
2121
|
-
const mtable = new
|
|
2100
|
+
const mtable = new MathNode("mtable", mtrs);
|
|
2122
2101
|
if (!isDisplayMode) {
|
|
2123
2102
|
mtable.setAttribute("columnalign", "left");
|
|
2124
2103
|
mtable.setAttribute("rowspacing", "0em");
|
|
2125
2104
|
}
|
|
2126
2105
|
return mtable
|
|
2127
2106
|
}
|
|
2128
|
-
return
|
|
2107
|
+
return newDocumentFragment(mrows);
|
|
2129
2108
|
}
|
|
2130
2109
|
|
|
2131
2110
|
/**
|
|
@@ -2154,15 +2133,15 @@ const makeText = function(text, mode, style) {
|
|
|
2154
2133
|
text = symbols[mode][text].replace;
|
|
2155
2134
|
}
|
|
2156
2135
|
|
|
2157
|
-
return new
|
|
2136
|
+
return new TextNode(text);
|
|
2158
2137
|
};
|
|
2159
2138
|
|
|
2160
2139
|
const copyChar = (newRow, child) => {
|
|
2161
2140
|
if (newRow.children.length === 0 ||
|
|
2162
2141
|
newRow.children[newRow.children.length - 1].type !== "mtext") {
|
|
2163
|
-
const mtext = new
|
|
2142
|
+
const mtext = new MathNode(
|
|
2164
2143
|
"mtext",
|
|
2165
|
-
[new
|
|
2144
|
+
[new TextNode(child.children[0].text)]
|
|
2166
2145
|
);
|
|
2167
2146
|
newRow.children.push(mtext);
|
|
2168
2147
|
} else {
|
|
@@ -2174,7 +2153,7 @@ const consolidateText = mrow => {
|
|
|
2174
2153
|
// If possible, consolidate adjacent <mtext> elements into a single element.
|
|
2175
2154
|
if (mrow.type !== "mrow" && mrow.type !== "mstyle") { return mrow }
|
|
2176
2155
|
if (mrow.children.length === 0) { return mrow } // empty group, e.g., \text{}
|
|
2177
|
-
const newRow = new
|
|
2156
|
+
const newRow = new MathNode("mrow");
|
|
2178
2157
|
for (let i = 0; i < mrow.children.length; i++) {
|
|
2179
2158
|
const child = mrow.children[i];
|
|
2180
2159
|
if (child.type === "mtext" && Object.keys(child.attributes).length === 0) {
|
|
@@ -2244,7 +2223,7 @@ const makeRow = function(body, semisimple = false) {
|
|
|
2244
2223
|
body[end].attributes.rspace = "0em";
|
|
2245
2224
|
}
|
|
2246
2225
|
}
|
|
2247
|
-
return new
|
|
2226
|
+
return new MathNode("mrow", body);
|
|
2248
2227
|
};
|
|
2249
2228
|
|
|
2250
2229
|
/**
|
|
@@ -2369,7 +2348,7 @@ const buildExpressionRow = function(expression, style, semisimple = false) {
|
|
|
2369
2348
|
*/
|
|
2370
2349
|
const buildGroup$1 = function(group, style) {
|
|
2371
2350
|
if (!group) {
|
|
2372
|
-
return new
|
|
2351
|
+
return new MathNode("mrow");
|
|
2373
2352
|
}
|
|
2374
2353
|
|
|
2375
2354
|
if (_mathmlGroupBuilders[group.type]) {
|
|
@@ -2382,7 +2361,7 @@ const buildGroup$1 = function(group, style) {
|
|
|
2382
2361
|
};
|
|
2383
2362
|
|
|
2384
2363
|
const glue$1 = _ => {
|
|
2385
|
-
return new
|
|
2364
|
+
return new MathNode("mtd", [], [], { padding: "0", width: "50%" })
|
|
2386
2365
|
};
|
|
2387
2366
|
|
|
2388
2367
|
const labelContainers = ["mrow", "mtd", "mtable", "mtr"];
|
|
@@ -2409,12 +2388,12 @@ const taggedExpression = (expression, tag, style, leqno) => {
|
|
|
2409
2388
|
tag.classes.push("tml-tag"); // to be available for \ref
|
|
2410
2389
|
|
|
2411
2390
|
const label = getLabel(expression); // from a \label{} function.
|
|
2412
|
-
expression = new
|
|
2391
|
+
expression = new MathNode("mtd", [expression]);
|
|
2413
2392
|
const rowArray = [glue$1(), expression, glue$1()];
|
|
2414
2393
|
rowArray[leqno ? 0 : 2].children.push(tag);
|
|
2415
|
-
const mtr = new
|
|
2394
|
+
const mtr = new MathNode("mtr", rowArray, ["tml-tageqn"]);
|
|
2416
2395
|
if (label) { mtr.setAttribute("id", label); }
|
|
2417
|
-
const table = new
|
|
2396
|
+
const table = new MathNode("mtable", [mtr]);
|
|
2418
2397
|
table.style.width = "100%";
|
|
2419
2398
|
table.setAttribute("displaystyle", "true");
|
|
2420
2399
|
return table
|
|
@@ -2451,13 +2430,13 @@ function buildMathML(tree, texExpression, style, settings) {
|
|
|
2451
2430
|
|
|
2452
2431
|
if (settings.annotate) {
|
|
2453
2432
|
// Build a TeX annotation of the source
|
|
2454
|
-
const annotation = new
|
|
2455
|
-
"annotation", [new
|
|
2433
|
+
const annotation = new MathNode(
|
|
2434
|
+
"annotation", [new TextNode(texExpression)]);
|
|
2456
2435
|
annotation.setAttribute("encoding", "application/x-tex");
|
|
2457
|
-
wrapper = new
|
|
2436
|
+
wrapper = new MathNode("semantics", [wrapper, annotation]);
|
|
2458
2437
|
}
|
|
2459
2438
|
|
|
2460
|
-
const math = new
|
|
2439
|
+
const math = new MathNode("math", [wrapper]);
|
|
2461
2440
|
|
|
2462
2441
|
if (settings.xml) {
|
|
2463
2442
|
math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
|
|
@@ -2481,14 +2460,14 @@ const mediumNudge = "BCEGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ";
|
|
|
2481
2460
|
const largeNudge = "AFJdfΔΛ";
|
|
2482
2461
|
|
|
2483
2462
|
const mathmlBuilder$a = (group, style) => {
|
|
2484
|
-
const accentNode = group.isStretchy
|
|
2485
|
-
?
|
|
2486
|
-
: new
|
|
2463
|
+
const accentNode$1 = group.isStretchy
|
|
2464
|
+
? accentNode(group)
|
|
2465
|
+
: new MathNode("mo", [makeText(group.label, group.mode)]);
|
|
2487
2466
|
if (!group.isStretchy) {
|
|
2488
|
-
accentNode.setAttribute("stretchy", "false"); // Keep Firefox from stretching \check
|
|
2467
|
+
accentNode$1.setAttribute("stretchy", "false"); // Keep Firefox from stretching \check
|
|
2489
2468
|
}
|
|
2490
2469
|
if (group.label !== "\\vec") {
|
|
2491
|
-
accentNode.style.mathDepth = "0"; // not scriptstyle
|
|
2470
|
+
accentNode$1.style.mathDepth = "0"; // not scriptstyle
|
|
2492
2471
|
// Don't use attribute accent="true" because MathML Core eliminates a needed space.
|
|
2493
2472
|
}
|
|
2494
2473
|
const tag = group.label === "\\c" ? "munder" : "mover";
|
|
@@ -2499,28 +2478,28 @@ const mathmlBuilder$a = (group, style) => {
|
|
|
2499
2478
|
const isVec = group.label === "\\vec";
|
|
2500
2479
|
const vecPostfix = isVec === "\\vec" ? "-vec" : "";
|
|
2501
2480
|
if (isVec) {
|
|
2502
|
-
accentNode.classes.push("tml-vec"); // Firefox sizing of \vec arrow
|
|
2481
|
+
accentNode$1.classes.push("tml-vec"); // Firefox sizing of \vec arrow
|
|
2503
2482
|
}
|
|
2504
2483
|
const wbkPostfix = isVec ? "-vec" : needsWbkVertShift ? "-acc" : "";
|
|
2505
2484
|
if (smallNudge.indexOf(text) > -1) {
|
|
2506
|
-
accentNode.classes.push(`chr-sml${vecPostfix}`);
|
|
2507
|
-
accentNode.classes.push(`wbk-sml${wbkPostfix}`);
|
|
2485
|
+
accentNode$1.classes.push(`chr-sml${vecPostfix}`);
|
|
2486
|
+
accentNode$1.classes.push(`wbk-sml${wbkPostfix}`);
|
|
2508
2487
|
} else if (mediumNudge.indexOf(text) > -1) {
|
|
2509
|
-
accentNode.classes.push(`chr-med${vecPostfix}`);
|
|
2510
|
-
accentNode.classes.push(`wbk-med${wbkPostfix}`);
|
|
2488
|
+
accentNode$1.classes.push(`chr-med${vecPostfix}`);
|
|
2489
|
+
accentNode$1.classes.push(`wbk-med${wbkPostfix}`);
|
|
2511
2490
|
} else if (largeNudge.indexOf(text) > -1) {
|
|
2512
|
-
accentNode.classes.push(`chr-lrg${vecPostfix}`);
|
|
2513
|
-
accentNode.classes.push(`wbk-lrg${wbkPostfix}`);
|
|
2491
|
+
accentNode$1.classes.push(`chr-lrg${vecPostfix}`);
|
|
2492
|
+
accentNode$1.classes.push(`wbk-lrg${wbkPostfix}`);
|
|
2514
2493
|
} else if (isVec) {
|
|
2515
|
-
accentNode.classes.push(`wbk-vec`);
|
|
2494
|
+
accentNode$1.classes.push(`wbk-vec`);
|
|
2516
2495
|
} else if (needsWbkVertShift) {
|
|
2517
|
-
accentNode.classes.push(`wbk-acc`);
|
|
2496
|
+
accentNode$1.classes.push(`wbk-acc`);
|
|
2518
2497
|
}
|
|
2519
2498
|
} else if (needsWbkVertShift) {
|
|
2520
2499
|
// text-mode accents
|
|
2521
|
-
accentNode.classes.push("wbk-acc");
|
|
2500
|
+
accentNode$1.classes.push("wbk-acc");
|
|
2522
2501
|
}
|
|
2523
|
-
const node = new
|
|
2502
|
+
const node = new MathNode(tag, [buildGroup$1(group.base, style), accentNode$1]);
|
|
2524
2503
|
return node;
|
|
2525
2504
|
};
|
|
2526
2505
|
|
|
@@ -2687,11 +2666,11 @@ defineFunction({
|
|
|
2687
2666
|
};
|
|
2688
2667
|
},
|
|
2689
2668
|
mathmlBuilder: (group, style) => {
|
|
2690
|
-
const accentNode =
|
|
2691
|
-
accentNode.style["math-depth"] = 0;
|
|
2692
|
-
const node = new
|
|
2669
|
+
const accentNode$1 = accentNode(group);
|
|
2670
|
+
accentNode$1.style["math-depth"] = 0;
|
|
2671
|
+
const node = new MathNode("munder", [
|
|
2693
2672
|
buildGroup$1(group.base, style),
|
|
2694
|
-
accentNode
|
|
2673
|
+
accentNode$1
|
|
2695
2674
|
]);
|
|
2696
2675
|
return node;
|
|
2697
2676
|
}
|
|
@@ -2780,7 +2759,7 @@ const calculateSize = function(sizeValue, style) {
|
|
|
2780
2759
|
// In TeX, em and ex do not change size in \scriptstyle.
|
|
2781
2760
|
if (unit === "ex") { number *= 0.431; }
|
|
2782
2761
|
number = Math.min(number / emScale(style.level), style.maxSize[0]);
|
|
2783
|
-
return { number:
|
|
2762
|
+
return { number: round(number), unit: "em" };
|
|
2784
2763
|
}
|
|
2785
2764
|
case "bp": {
|
|
2786
2765
|
if (number > style.maxSize[1]) { number = style.maxSize[1]; }
|
|
@@ -2794,11 +2773,11 @@ const calculateSize = function(sizeValue, style) {
|
|
|
2794
2773
|
case "nc":
|
|
2795
2774
|
case "sp": {
|
|
2796
2775
|
number = Math.min(number * ptPerUnit[unit], style.maxSize[1]);
|
|
2797
|
-
return { number:
|
|
2776
|
+
return { number: round(number), unit: "pt" }
|
|
2798
2777
|
}
|
|
2799
2778
|
case "mu": {
|
|
2800
2779
|
number = Math.min(number / 18, style.maxSize[0]);
|
|
2801
|
-
return { number:
|
|
2780
|
+
return { number: round(number), unit: "em" }
|
|
2802
2781
|
}
|
|
2803
2782
|
default:
|
|
2804
2783
|
throw new ParseError("Invalid unit: '" + unit + "'")
|
|
@@ -2808,7 +2787,7 @@ const calculateSize = function(sizeValue, style) {
|
|
|
2808
2787
|
// Helper functions
|
|
2809
2788
|
|
|
2810
2789
|
const padding = width => {
|
|
2811
|
-
const node = new
|
|
2790
|
+
const node = new MathNode("mspace");
|
|
2812
2791
|
node.setAttribute("width", width + "em");
|
|
2813
2792
|
return node
|
|
2814
2793
|
};
|
|
@@ -2820,18 +2799,18 @@ const paddedNode = (group, lspace = 0.3, rspace = 0, mustSmash = false) => {
|
|
|
2820
2799
|
if (rspace > 0) { row.push(padding(rspace)); }
|
|
2821
2800
|
if (mustSmash) {
|
|
2822
2801
|
// Used for the bottom arrow in a {CD} environment
|
|
2823
|
-
const mpadded = new
|
|
2802
|
+
const mpadded = new MathNode("mpadded", row);
|
|
2824
2803
|
mpadded.setAttribute("height", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
2825
2804
|
return mpadded
|
|
2826
2805
|
} else {
|
|
2827
|
-
return new
|
|
2806
|
+
return new MathNode("mrow", row)
|
|
2828
2807
|
}
|
|
2829
2808
|
};
|
|
2830
2809
|
|
|
2831
2810
|
const labelSize = (size, scriptLevel) => Number(size) / emScale(scriptLevel);
|
|
2832
2811
|
|
|
2833
2812
|
const munderoverNode = (fName, body, below, style) => {
|
|
2834
|
-
const arrowNode =
|
|
2813
|
+
const arrowNode = mathMLnode(fName);
|
|
2835
2814
|
// Is this the short part of a mhchem equilibrium arrow?
|
|
2836
2815
|
const isEq = fName.slice(1, 3) === "eq";
|
|
2837
2816
|
const minWidth = fName.charAt(1) === "x"
|
|
@@ -2870,25 +2849,25 @@ const munderoverNode = (fName, body, below, style) => {
|
|
|
2870
2849
|
// Since Firefox does not support minsize, stack a invisible node
|
|
2871
2850
|
// on top of the label. Its width will serve as a min-width.
|
|
2872
2851
|
// TODO: Refactor this after Firefox supports minsize.
|
|
2873
|
-
upperNode = new
|
|
2852
|
+
upperNode = new MathNode("mover", [label, dummyNode]);
|
|
2874
2853
|
}
|
|
2875
2854
|
const gotLower = (below && below.body &&
|
|
2876
2855
|
(below.body.body || below.body.length > 0));
|
|
2877
2856
|
if (gotLower) {
|
|
2878
2857
|
let label = buildGroup$1(below, labelStyle);
|
|
2879
2858
|
label = paddedNode(label, space, space);
|
|
2880
|
-
lowerNode = new
|
|
2859
|
+
lowerNode = new MathNode("munder", [label, dummyNode]);
|
|
2881
2860
|
}
|
|
2882
2861
|
|
|
2883
2862
|
let node;
|
|
2884
2863
|
if (!gotUpper && !gotLower) {
|
|
2885
|
-
node = new
|
|
2864
|
+
node = new MathNode("mover", [arrowNode, emptyLabel]);
|
|
2886
2865
|
} else if (gotUpper && gotLower) {
|
|
2887
|
-
node = new
|
|
2866
|
+
node = new MathNode("munderover", [arrowNode, lowerNode, upperNode]);
|
|
2888
2867
|
} else if (gotUpper) {
|
|
2889
|
-
node = new
|
|
2868
|
+
node = new MathNode("mover", [arrowNode, upperNode]);
|
|
2890
2869
|
} else {
|
|
2891
|
-
node = new
|
|
2870
|
+
node = new MathNode("munder", [arrowNode, lowerNode]);
|
|
2892
2871
|
}
|
|
2893
2872
|
if (minWidth === "3.0") { node.style.height = "1em"; } // CD environment
|
|
2894
2873
|
node.setAttribute("accent", "false"); // Necessary for MS Word
|
|
@@ -2951,7 +2930,7 @@ defineFunction({
|
|
|
2951
2930
|
const row = [node];
|
|
2952
2931
|
row.unshift(padding(0.2778));
|
|
2953
2932
|
row.push(padding(0.2778));
|
|
2954
|
-
return new
|
|
2933
|
+
return new MathNode("mrow", row)
|
|
2955
2934
|
}
|
|
2956
2935
|
});
|
|
2957
2936
|
|
|
@@ -3004,21 +2983,21 @@ defineFunction({
|
|
|
3004
2983
|
const botArrow = munderoverNode(botLabel, group.lowerArrowBody, group.below, style);
|
|
3005
2984
|
let wrapper;
|
|
3006
2985
|
|
|
3007
|
-
const raiseNode = new
|
|
2986
|
+
const raiseNode = new MathNode("mpadded", [topArrow]);
|
|
3008
2987
|
raiseNode.setAttribute("voffset", "0.3em");
|
|
3009
2988
|
raiseNode.setAttribute("height", "+0.3em");
|
|
3010
2989
|
raiseNode.setAttribute("depth", "-0.3em");
|
|
3011
2990
|
// One of the arrows is given ~zero width. so the other has the same horzontal alignment.
|
|
3012
2991
|
if (group.name === "\\equilibriumLeft") {
|
|
3013
|
-
const botNode = new
|
|
2992
|
+
const botNode = new MathNode("mpadded", [botArrow]);
|
|
3014
2993
|
botNode.setAttribute("width", "0.5em");
|
|
3015
|
-
wrapper = new
|
|
2994
|
+
wrapper = new MathNode(
|
|
3016
2995
|
"mpadded",
|
|
3017
2996
|
[padding(0.2778), botNode, raiseNode, padding(0.2778)]
|
|
3018
2997
|
);
|
|
3019
2998
|
} else {
|
|
3020
2999
|
raiseNode.setAttribute("width", (group.name === "\\equilibriumRight" ? "0.5em" : "0"));
|
|
3021
|
-
wrapper = new
|
|
3000
|
+
wrapper = new MathNode(
|
|
3022
3001
|
"mpadded",
|
|
3023
3002
|
[padding(0.2778), raiseNode, botArrow, padding(0.2778)]
|
|
3024
3003
|
);
|
|
@@ -3310,18 +3289,18 @@ defineFunction({
|
|
|
3310
3289
|
},
|
|
3311
3290
|
mathmlBuilder(group, style) {
|
|
3312
3291
|
if (group.label.body.length === 0) {
|
|
3313
|
-
return new
|
|
3292
|
+
return new MathNode("mrow", style) // empty label
|
|
3314
3293
|
}
|
|
3315
3294
|
// Abuse an <mtable> to create vertically centered content.
|
|
3316
3295
|
const mrow = buildGroup$1(group.label, style);
|
|
3317
3296
|
if (group.side === "left") {
|
|
3318
3297
|
mrow.classes.push("tml-shift-left");
|
|
3319
3298
|
}
|
|
3320
|
-
const mtd = new
|
|
3299
|
+
const mtd = new MathNode("mtd", [mrow]);
|
|
3321
3300
|
mtd.style.padding = "0";
|
|
3322
|
-
const mtr = new
|
|
3323
|
-
const mtable = new
|
|
3324
|
-
const label = new
|
|
3301
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
3302
|
+
const mtable = new MathNode("mtable", [mtr]);
|
|
3303
|
+
const label = new MathNode("mpadded", [mtable]);
|
|
3325
3304
|
// Set the label width to zero so that the arrow will be centered under the corner cell.
|
|
3326
3305
|
label.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
3327
3306
|
label.setAttribute("displaystyle", "false");
|
|
@@ -3344,7 +3323,7 @@ defineFunction({
|
|
|
3344
3323
|
};
|
|
3345
3324
|
},
|
|
3346
3325
|
mathmlBuilder(group, style) {
|
|
3347
|
-
return new
|
|
3326
|
+
return new MathNode("mrow", [buildGroup$1(group.fragment, style)]);
|
|
3348
3327
|
}
|
|
3349
3328
|
});
|
|
3350
3329
|
|
|
@@ -6443,7 +6422,7 @@ const alignMap = {
|
|
|
6443
6422
|
};
|
|
6444
6423
|
|
|
6445
6424
|
const glue = group => {
|
|
6446
|
-
const glueNode = new
|
|
6425
|
+
const glueNode = new MathNode("mtd", []);
|
|
6447
6426
|
glueNode.style = { padding: "0", width: "50%" };
|
|
6448
6427
|
if (group.envClasses.includes("multline")) {
|
|
6449
6428
|
glueNode.style.width = "7.5%";
|
|
@@ -6466,7 +6445,7 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6466
6445
|
: StyleLevel.DISPLAY;
|
|
6467
6446
|
|
|
6468
6447
|
for (let j = 0; j < rw.length; j++) {
|
|
6469
|
-
const mtd = new
|
|
6448
|
+
const mtd = new MathNode(
|
|
6470
6449
|
"mtd",
|
|
6471
6450
|
[buildGroup$1(rw[j], style.withLevel(cellLevel))]
|
|
6472
6451
|
);
|
|
@@ -6482,16 +6461,16 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6482
6461
|
const numColumns = group.body[0].length;
|
|
6483
6462
|
// Fill out a short row with empty <mtd> elements.
|
|
6484
6463
|
for (let k = 0; k < numColumns - rw.length; k++) {
|
|
6485
|
-
row.push(new
|
|
6464
|
+
row.push(new MathNode("mtd", [], [], style));
|
|
6486
6465
|
}
|
|
6487
6466
|
if (group.autoTag) {
|
|
6488
6467
|
const tag = group.tags[i];
|
|
6489
6468
|
let tagElement;
|
|
6490
6469
|
if (tag === true) { // automatic numbering
|
|
6491
|
-
tagElement = new
|
|
6470
|
+
tagElement = new MathNode("mtext", [new Span(["tml-eqn"])]);
|
|
6492
6471
|
} else if (tag === false) {
|
|
6493
6472
|
// \nonumber/\notag or starred environment
|
|
6494
|
-
tagElement = new
|
|
6473
|
+
tagElement = new MathNode("mtext", [], []);
|
|
6495
6474
|
} else { // manual \tag
|
|
6496
6475
|
tagElement = buildExpressionRow(tag[0].body, style.withLevel(cellLevel), true);
|
|
6497
6476
|
tagElement = consolidateText(tagElement);
|
|
@@ -6507,7 +6486,7 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6507
6486
|
}
|
|
6508
6487
|
}
|
|
6509
6488
|
}
|
|
6510
|
-
const mtr = new
|
|
6489
|
+
const mtr = new MathNode("mtr", row, []);
|
|
6511
6490
|
const label = group.labels.shift();
|
|
6512
6491
|
if (label && group.tags && group.tags[i]) {
|
|
6513
6492
|
mtr.setAttribute("id", label);
|
|
@@ -6649,7 +6628,7 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6649
6628
|
}
|
|
6650
6629
|
}
|
|
6651
6630
|
|
|
6652
|
-
let table = new
|
|
6631
|
+
let table = new MathNode("mtable", tbl);
|
|
6653
6632
|
if (group.envClasses.length > 0) {
|
|
6654
6633
|
// Top & bottom padding
|
|
6655
6634
|
if (group.envClasses.includes("jot")) {
|
|
@@ -6733,7 +6712,7 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6733
6712
|
|
|
6734
6713
|
if (group.envClasses.includes("small")) {
|
|
6735
6714
|
// A small array. Wrap in scriptstyle.
|
|
6736
|
-
table = new
|
|
6715
|
+
table = new MathNode("mstyle", [table]);
|
|
6737
6716
|
table.setAttribute("scriptlevel", "1");
|
|
6738
6717
|
}
|
|
6739
6718
|
|
|
@@ -6980,9 +6959,8 @@ defineEnvironment({
|
|
|
6980
6959
|
numArgs: 0
|
|
6981
6960
|
},
|
|
6982
6961
|
handler(context) {
|
|
6983
|
-
const payload = {
|
|
6962
|
+
const payload = { envClasses: ["small"] };
|
|
6984
6963
|
const res = parseArray(context.parser, payload, "script");
|
|
6985
|
-
res.envClasses = ["small"];
|
|
6986
6964
|
return res;
|
|
6987
6965
|
},
|
|
6988
6966
|
mathmlBuilder: mathmlBuilder$9
|
|
@@ -7399,13 +7377,13 @@ const mathmlBuilder$8 = (group, style) => {
|
|
|
7399
7377
|
// the color individually to each node and return a document fragment.
|
|
7400
7378
|
let expr = buildExpression(group.body, style.withColor(group.color));
|
|
7401
7379
|
if (expr.length === 0) {
|
|
7402
|
-
expr.push(new
|
|
7380
|
+
expr.push(new MathNode("mrow"));
|
|
7403
7381
|
}
|
|
7404
7382
|
expr = expr.map(e => {
|
|
7405
7383
|
e.style.color = group.color;
|
|
7406
7384
|
return e
|
|
7407
7385
|
});
|
|
7408
|
-
return
|
|
7386
|
+
return newDocumentFragment(expr)
|
|
7409
7387
|
};
|
|
7410
7388
|
|
|
7411
7389
|
defineFunction({
|
|
@@ -7526,7 +7504,7 @@ defineFunction({
|
|
|
7526
7504
|
mathmlBuilder(group, style) {
|
|
7527
7505
|
// MathML 3.0 calls for newline to occur in an <mo> or an <mspace>.
|
|
7528
7506
|
// Ref: https://www.w3.org/TR/MathML3/chapter3.html#presm.linebreaking
|
|
7529
|
-
const node = new
|
|
7507
|
+
const node = new MathNode("mo");
|
|
7530
7508
|
if (group.newLine) {
|
|
7531
7509
|
node.setAttribute("linebreak", "newline");
|
|
7532
7510
|
if (group.size) {
|
|
@@ -7981,7 +7959,7 @@ defineFunction({
|
|
|
7981
7959
|
if (group.delim === ".") { group.delim = ""; }
|
|
7982
7960
|
children.push(makeText(group.delim, group.mode));
|
|
7983
7961
|
|
|
7984
|
-
const node = new
|
|
7962
|
+
const node = new MathNode("mo", children);
|
|
7985
7963
|
|
|
7986
7964
|
if (group.mclass === "mopen" || group.mclass === "mclose") {
|
|
7987
7965
|
// Only some of the delimsizing functions act as fences, and they
|
|
@@ -8075,7 +8053,7 @@ defineFunction({
|
|
|
8075
8053
|
const inner = buildExpression(group.body, style);
|
|
8076
8054
|
|
|
8077
8055
|
if (group.left === ".") { group.left = ""; }
|
|
8078
|
-
const leftNode = new
|
|
8056
|
+
const leftNode = new MathNode("mo", [makeText(group.left, group.mode)]);
|
|
8079
8057
|
leftNode.setAttribute("fence", "true");
|
|
8080
8058
|
leftNode.setAttribute("form", "prefix");
|
|
8081
8059
|
if (group.left === "/" || group.left === "\u005C" || group.left.indexOf("arrow") > -1) {
|
|
@@ -8084,7 +8062,7 @@ defineFunction({
|
|
|
8084
8062
|
inner.unshift(leftNode);
|
|
8085
8063
|
|
|
8086
8064
|
if (group.right === ".") { group.right = ""; }
|
|
8087
|
-
const rightNode = new
|
|
8065
|
+
const rightNode = new MathNode("mo", [makeText(group.right, group.mode)]);
|
|
8088
8066
|
rightNode.setAttribute("fence", "true");
|
|
8089
8067
|
rightNode.setAttribute("form", "postfix");
|
|
8090
8068
|
if (group.right === "\u2216" || group.right.indexOf("arrow") > -1) {
|
|
@@ -8126,7 +8104,7 @@ defineFunction({
|
|
|
8126
8104
|
},
|
|
8127
8105
|
mathmlBuilder: (group, style) => {
|
|
8128
8106
|
const textNode = makeText(group.delim, group.mode);
|
|
8129
|
-
const middleNode = new
|
|
8107
|
+
const middleNode = new MathNode("mo", [textNode]);
|
|
8130
8108
|
middleNode.setAttribute("fence", "true");
|
|
8131
8109
|
if (group.delim.indexOf("arrow") > -1) {
|
|
8132
8110
|
middleNode.setAttribute("stretchy", "true");
|
|
@@ -8143,7 +8121,8 @@ defineFunction({
|
|
|
8143
8121
|
});
|
|
8144
8122
|
|
|
8145
8123
|
const mathmlBuilder$7 = (group, style) => {
|
|
8146
|
-
const
|
|
8124
|
+
const tag = group.label === "\\boxed" ? "mrow" : "menclose";
|
|
8125
|
+
const node = new MathNode(tag, [buildGroup$1(group.body, style)]);
|
|
8147
8126
|
switch (group.label) {
|
|
8148
8127
|
case "\\overline":
|
|
8149
8128
|
node.setAttribute("notation", "top"); // for Firefox & WebKit
|
|
@@ -8155,15 +8134,15 @@ const mathmlBuilder$7 = (group, style) => {
|
|
|
8155
8134
|
break
|
|
8156
8135
|
case "\\cancel":
|
|
8157
8136
|
node.setAttribute("notation", "updiagonalstrike");
|
|
8158
|
-
node.children.push(new
|
|
8137
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "upstrike"]));
|
|
8159
8138
|
break
|
|
8160
8139
|
case "\\bcancel":
|
|
8161
8140
|
node.setAttribute("notation", "downdiagonalstrike");
|
|
8162
|
-
node.children.push(new
|
|
8141
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "downstrike"]));
|
|
8163
8142
|
break
|
|
8164
8143
|
case "\\sout":
|
|
8165
8144
|
node.setAttribute("notation", "horizontalstrike");
|
|
8166
|
-
node.children.push(new
|
|
8145
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "sout"]));
|
|
8167
8146
|
break
|
|
8168
8147
|
case "\\xcancel":
|
|
8169
8148
|
node.setAttribute("notation", "updiagonalstrike downdiagonalstrike");
|
|
@@ -8172,17 +8151,17 @@ const mathmlBuilder$7 = (group, style) => {
|
|
|
8172
8151
|
case "\\longdiv":
|
|
8173
8152
|
node.setAttribute("notation", "longdiv");
|
|
8174
8153
|
node.classes.push("longdiv-top");
|
|
8175
|
-
node.children.push(new
|
|
8154
|
+
node.children.push(new MathNode("mrow", [], ["longdiv-arc"]));
|
|
8176
8155
|
break
|
|
8177
8156
|
case "\\phase":
|
|
8178
8157
|
node.setAttribute("notation", "phasorangle");
|
|
8179
8158
|
node.classes.push("phasor-bottom");
|
|
8180
|
-
node.children.push(new
|
|
8159
|
+
node.children.push(new MathNode("mrow", [], ["phasor-angle"]));
|
|
8181
8160
|
break
|
|
8182
8161
|
case "\\textcircled":
|
|
8183
8162
|
node.setAttribute("notation", "circle");
|
|
8184
8163
|
node.classes.push("circle-pad");
|
|
8185
|
-
node.children.push(new
|
|
8164
|
+
node.children.push(new MathNode("mrow", [], ["textcircle"]));
|
|
8186
8165
|
break
|
|
8187
8166
|
case "\\angl":
|
|
8188
8167
|
node.setAttribute("notation", "actuarial");
|
|
@@ -8190,7 +8169,6 @@ const mathmlBuilder$7 = (group, style) => {
|
|
|
8190
8169
|
break
|
|
8191
8170
|
case "\\boxed":
|
|
8192
8171
|
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
|
|
8193
|
-
node.setAttribute("notation", "box");
|
|
8194
8172
|
node.style.padding = "3pt";
|
|
8195
8173
|
node.style.border = "1px solid";
|
|
8196
8174
|
node.setAttribute("scriptlevel", "0");
|
|
@@ -8434,7 +8412,7 @@ defineFunction({
|
|
|
8434
8412
|
};
|
|
8435
8413
|
},
|
|
8436
8414
|
mathmlBuilder(group, style) {
|
|
8437
|
-
return new
|
|
8415
|
+
return new MathNode("mrow");
|
|
8438
8416
|
}
|
|
8439
8417
|
});
|
|
8440
8418
|
|
|
@@ -8451,7 +8429,7 @@ defineFunction({
|
|
|
8451
8429
|
};
|
|
8452
8430
|
},
|
|
8453
8431
|
mathmlBuilder(group, style) {
|
|
8454
|
-
return new
|
|
8432
|
+
return new MathNode("mrow");
|
|
8455
8433
|
}
|
|
8456
8434
|
});
|
|
8457
8435
|
|
|
@@ -8494,7 +8472,7 @@ const mathmlBuilder$6 = (group, style) => {
|
|
|
8494
8472
|
: mathGroup.children[i].children[0].text;
|
|
8495
8473
|
}
|
|
8496
8474
|
// Wrap in a <mpadded> to prevent the same Firefox bug.
|
|
8497
|
-
const mpadded = new
|
|
8475
|
+
const mpadded = new MathNode("mpadded", [mi]);
|
|
8498
8476
|
mpadded.setAttribute("lspace", "0");
|
|
8499
8477
|
return mpadded
|
|
8500
8478
|
}
|
|
@@ -8520,8 +8498,8 @@ const mathmlBuilder$6 = (group, style) => {
|
|
|
8520
8498
|
// Ref: https://bugs.webkit.org/show_bug.cgi?id=129097
|
|
8521
8499
|
// We insert a text node that contains a zero-width space and wrap in an mrow.
|
|
8522
8500
|
// TODO: Get rid of this <mi> workaround when the Firefox bug is fixed.
|
|
8523
|
-
const bogus = new
|
|
8524
|
-
return new
|
|
8501
|
+
const bogus = new MathNode("mtext", new TextNode("\u200b"));
|
|
8502
|
+
return new MathNode("mrow", [bogus, mi])
|
|
8525
8503
|
}
|
|
8526
8504
|
return mi
|
|
8527
8505
|
};
|
|
@@ -8632,7 +8610,7 @@ const mathmlBuilder$5 = (group, style) => {
|
|
|
8632
8610
|
denom.setAttribute("scriptlevel", "2");
|
|
8633
8611
|
}
|
|
8634
8612
|
|
|
8635
|
-
let node = new
|
|
8613
|
+
let node = new MathNode("mfrac", [numer, denom]);
|
|
8636
8614
|
|
|
8637
8615
|
if (!group.hasBarLine) {
|
|
8638
8616
|
node.setAttribute("linethickness", "0px");
|
|
@@ -8645,8 +8623,8 @@ const mathmlBuilder$5 = (group, style) => {
|
|
|
8645
8623
|
const withDelims = [];
|
|
8646
8624
|
|
|
8647
8625
|
if (group.leftDelim != null) {
|
|
8648
|
-
const leftOp = new
|
|
8649
|
-
new
|
|
8626
|
+
const leftOp = new MathNode("mo", [
|
|
8627
|
+
new TextNode(group.leftDelim.replace("\\", ""))
|
|
8650
8628
|
]);
|
|
8651
8629
|
leftOp.setAttribute("fence", "true");
|
|
8652
8630
|
withDelims.push(leftOp);
|
|
@@ -8655,8 +8633,8 @@ const mathmlBuilder$5 = (group, style) => {
|
|
|
8655
8633
|
withDelims.push(node);
|
|
8656
8634
|
|
|
8657
8635
|
if (group.rightDelim != null) {
|
|
8658
|
-
const rightOp = new
|
|
8659
|
-
new
|
|
8636
|
+
const rightOp = new MathNode("mo", [
|
|
8637
|
+
new TextNode(group.rightDelim.replace("\\", ""))
|
|
8660
8638
|
]);
|
|
8661
8639
|
rightOp.setAttribute("fence", "true");
|
|
8662
8640
|
withDelims.push(rightOp);
|
|
@@ -8666,7 +8644,7 @@ const mathmlBuilder$5 = (group, style) => {
|
|
|
8666
8644
|
}
|
|
8667
8645
|
|
|
8668
8646
|
if (group.scriptLevel !== "auto") {
|
|
8669
|
-
node = new
|
|
8647
|
+
node = new MathNode("mstyle", [node]);
|
|
8670
8648
|
node.setAttribute("displaystyle", String(group.scriptLevel === "display"));
|
|
8671
8649
|
node.setAttribute("scriptlevel", scriptLevel[group.scriptLevel]);
|
|
8672
8650
|
}
|
|
@@ -8969,9 +8947,9 @@ defineFunction({
|
|
|
8969
8947
|
});
|
|
8970
8948
|
|
|
8971
8949
|
const mathmlBuilder$4 = (group, style) => {
|
|
8972
|
-
const accentNode =
|
|
8950
|
+
const accentNode = mathMLnode(group.label);
|
|
8973
8951
|
accentNode.style["math-depth"] = 0;
|
|
8974
|
-
return new
|
|
8952
|
+
return new MathNode(group.isOver ? "mover" : "munder", [
|
|
8975
8953
|
buildGroup$1(group.base, style),
|
|
8976
8954
|
accentNode
|
|
8977
8955
|
]);
|
|
@@ -9207,7 +9185,7 @@ defineFunction({
|
|
|
9207
9185
|
const node = new Img(group.src, group.alt, graphicStyle);
|
|
9208
9186
|
node.height = height;
|
|
9209
9187
|
node.depth = depth;
|
|
9210
|
-
return new
|
|
9188
|
+
return new MathNode("mtext", [node])
|
|
9211
9189
|
}
|
|
9212
9190
|
});
|
|
9213
9191
|
|
|
@@ -9257,17 +9235,17 @@ defineFunction({
|
|
|
9257
9235
|
? spaceCharacter(dimension.number)
|
|
9258
9236
|
: "";
|
|
9259
9237
|
if (group.mode === "text" && ch.length > 0) {
|
|
9260
|
-
const character = new
|
|
9261
|
-
return new
|
|
9238
|
+
const character = new TextNode(ch);
|
|
9239
|
+
return new MathNode("mtext", [character]);
|
|
9262
9240
|
} else {
|
|
9263
9241
|
if (dimension.number >= 0) {
|
|
9264
|
-
const node = new
|
|
9242
|
+
const node = new MathNode("mspace");
|
|
9265
9243
|
node.setAttribute("width", dimension.number + dimension.unit);
|
|
9266
9244
|
return node
|
|
9267
9245
|
} else {
|
|
9268
9246
|
// Don't use <mspace> or <mpadded> because
|
|
9269
9247
|
// WebKit recognizes negative left margin only on a <mrow> element
|
|
9270
|
-
const node = new
|
|
9248
|
+
const node = new MathNode("mrow");
|
|
9271
9249
|
node.style.marginLeft = dimension.number + dimension.unit;
|
|
9272
9250
|
return node
|
|
9273
9251
|
}
|
|
@@ -9308,7 +9286,7 @@ defineFunction({
|
|
|
9308
9286
|
},
|
|
9309
9287
|
mathmlBuilder(group, style) {
|
|
9310
9288
|
// Return a no-width, no-ink element with an HTML id.
|
|
9311
|
-
const node = new
|
|
9289
|
+
const node = new MathNode("mrow", [], ["tml-label"]);
|
|
9312
9290
|
if (group.string.length > 0) {
|
|
9313
9291
|
node.setLabel(group.string);
|
|
9314
9292
|
}
|
|
@@ -9352,8 +9330,8 @@ defineFunction({
|
|
|
9352
9330
|
// We need an invisible strut with the same depth as the group.
|
|
9353
9331
|
// We can't just read the depth, so we use \vphantom methods.
|
|
9354
9332
|
const phantomInner = buildExpression(ordargument(group.body), style);
|
|
9355
|
-
const phantom = new
|
|
9356
|
-
strut = new
|
|
9333
|
+
const phantom = new MathNode("mphantom", phantomInner);
|
|
9334
|
+
strut = new MathNode("mpadded", [phantom]);
|
|
9357
9335
|
strut.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
9358
9336
|
}
|
|
9359
9337
|
|
|
@@ -9363,9 +9341,9 @@ defineFunction({
|
|
|
9363
9341
|
inner.style.position = "absolute";
|
|
9364
9342
|
inner.style.right = "0";
|
|
9365
9343
|
inner.style.bottom = `0`; // If we could have read the ink depth, it would go here.
|
|
9366
|
-
node = new
|
|
9344
|
+
node = new MathNode("mpadded", [strut, inner]);
|
|
9367
9345
|
} else {
|
|
9368
|
-
node = new
|
|
9346
|
+
node = new MathNode("mpadded", [inner]);
|
|
9369
9347
|
}
|
|
9370
9348
|
|
|
9371
9349
|
if (group.alignment === "rlap") {
|
|
@@ -9471,7 +9449,7 @@ function mathmlBuilder$3(group, style) {
|
|
|
9471
9449
|
const inner = buildExpression(group.body, style);
|
|
9472
9450
|
|
|
9473
9451
|
if (group.mclass === "minner") {
|
|
9474
|
-
node = new
|
|
9452
|
+
node = new MathNode("mpadded", inner);
|
|
9475
9453
|
} else if (group.mclass === "mord") {
|
|
9476
9454
|
if (group.isCharacterBox || inner[0].type === "mathord") {
|
|
9477
9455
|
node = inner[0];
|
|
@@ -9480,10 +9458,10 @@ function mathmlBuilder$3(group, style) {
|
|
|
9480
9458
|
node.setAttribute("mathvariant", "normal");
|
|
9481
9459
|
}
|
|
9482
9460
|
} else {
|
|
9483
|
-
node = new
|
|
9461
|
+
node = new MathNode("mi", inner);
|
|
9484
9462
|
}
|
|
9485
9463
|
} else {
|
|
9486
|
-
node = new
|
|
9464
|
+
node = new MathNode("mrow", inner);
|
|
9487
9465
|
if (group.mustPromote) {
|
|
9488
9466
|
node = inner[0];
|
|
9489
9467
|
node.type = "mo";
|
|
@@ -9491,7 +9469,7 @@ function mathmlBuilder$3(group, style) {
|
|
|
9491
9469
|
node.setAttribute("mathvariant", "italic");
|
|
9492
9470
|
}
|
|
9493
9471
|
} else {
|
|
9494
|
-
node = new
|
|
9472
|
+
node = new MathNode("mrow", inner);
|
|
9495
9473
|
}
|
|
9496
9474
|
|
|
9497
9475
|
// Set spacing based on what is the most likely adjacent atom type.
|
|
@@ -9561,7 +9539,7 @@ defineFunction({
|
|
|
9561
9539
|
},
|
|
9562
9540
|
handler({ parser, funcName }, args) {
|
|
9563
9541
|
const body = args[0];
|
|
9564
|
-
const isCharacterBox =
|
|
9542
|
+
const isCharacterBox$1 = isCharacterBox(body);
|
|
9565
9543
|
// We should not wrap a <mo> around a <mi> or <mord>. That would be invalid MathML.
|
|
9566
9544
|
// In that case, we instead promote the text contents of the body to the parent.
|
|
9567
9545
|
let mustPromote = true;
|
|
@@ -9590,7 +9568,7 @@ defineFunction({
|
|
|
9590
9568
|
mode: parser.mode,
|
|
9591
9569
|
mclass: "m" + funcName.slice(5),
|
|
9592
9570
|
body: ordargument(mustPromote ? mord : body),
|
|
9593
|
-
isCharacterBox,
|
|
9571
|
+
isCharacterBox: isCharacterBox$1,
|
|
9594
9572
|
mustPromote
|
|
9595
9573
|
};
|
|
9596
9574
|
}
|
|
@@ -9627,7 +9605,7 @@ defineFunction({
|
|
|
9627
9605
|
mode: parser.mode,
|
|
9628
9606
|
mclass: binrelClass(args[0]),
|
|
9629
9607
|
body: ordargument(args[1]),
|
|
9630
|
-
isCharacterBox:
|
|
9608
|
+
isCharacterBox: isCharacterBox(args[1])
|
|
9631
9609
|
};
|
|
9632
9610
|
}
|
|
9633
9611
|
});
|
|
@@ -9741,8 +9719,8 @@ defineFunction({
|
|
|
9741
9719
|
mathmlBuilder(group, style) {
|
|
9742
9720
|
const base = buildGroup$1(group.base, style);
|
|
9743
9721
|
|
|
9744
|
-
const prescriptsNode = new
|
|
9745
|
-
const noneNode = new
|
|
9722
|
+
const prescriptsNode = new MathNode("mprescripts");
|
|
9723
|
+
const noneNode = new MathNode("none");
|
|
9746
9724
|
let children = [];
|
|
9747
9725
|
|
|
9748
9726
|
const preSub = buildGroup(group.prescripts.sub, style, noneNode);
|
|
@@ -9761,7 +9739,7 @@ defineFunction({
|
|
|
9761
9739
|
children = [base, prescriptsNode, preSub, preSup];
|
|
9762
9740
|
}
|
|
9763
9741
|
|
|
9764
|
-
return new
|
|
9742
|
+
return new MathNode("mmultiscripts", children);
|
|
9765
9743
|
}
|
|
9766
9744
|
});
|
|
9767
9745
|
|
|
@@ -9774,9 +9752,9 @@ defineFunction({
|
|
|
9774
9752
|
allowedInText: false
|
|
9775
9753
|
},
|
|
9776
9754
|
handler({ parser }, args) {
|
|
9777
|
-
const isCharacterBox =
|
|
9755
|
+
const isCharacterBox$1 = isCharacterBox(args[0]);
|
|
9778
9756
|
let body;
|
|
9779
|
-
if (isCharacterBox) {
|
|
9757
|
+
if (isCharacterBox$1) {
|
|
9780
9758
|
body = ordargument(args[0]);
|
|
9781
9759
|
if (body[0].text.charAt(0) === "\\") {
|
|
9782
9760
|
body[0].text = symbols.math[body[0].text].replace;
|
|
@@ -9794,7 +9772,7 @@ defineFunction({
|
|
|
9794
9772
|
type: "not",
|
|
9795
9773
|
mode: parser.mode,
|
|
9796
9774
|
body,
|
|
9797
|
-
isCharacterBox
|
|
9775
|
+
isCharacterBox: isCharacterBox$1
|
|
9798
9776
|
};
|
|
9799
9777
|
},
|
|
9800
9778
|
mathmlBuilder(group, style) {
|
|
@@ -10173,9 +10151,9 @@ const mathmlBuilder$1 = (group, style) => {
|
|
|
10173
10151
|
let isAllString = true; // default
|
|
10174
10152
|
for (let i = 0; i < expression.length; i++) {
|
|
10175
10153
|
let node = expression[i];
|
|
10176
|
-
if (node instanceof
|
|
10154
|
+
if (node instanceof MathNode) {
|
|
10177
10155
|
if ((node.type === "mrow" || node.type === "mpadded") && node.children.length === 1 &&
|
|
10178
|
-
node.children[0] instanceof
|
|
10156
|
+
node.children[0] instanceof MathNode) {
|
|
10179
10157
|
node = node.children[0];
|
|
10180
10158
|
}
|
|
10181
10159
|
switch (node.type) {
|
|
@@ -10192,14 +10170,14 @@ const mathmlBuilder$1 = (group, style) => {
|
|
|
10192
10170
|
if (ch === "") {
|
|
10193
10171
|
isAllString = false;
|
|
10194
10172
|
} else {
|
|
10195
|
-
expression[i] = new
|
|
10173
|
+
expression[i] = new MathNode("mtext", [new TextNode(ch)]);
|
|
10196
10174
|
}
|
|
10197
10175
|
}
|
|
10198
10176
|
}
|
|
10199
10177
|
break
|
|
10200
10178
|
case "mo": {
|
|
10201
10179
|
const child = node.children[0];
|
|
10202
|
-
if (node.children.length === 1 && child instanceof
|
|
10180
|
+
if (node.children.length === 1 && child instanceof TextNode) {
|
|
10203
10181
|
child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
|
|
10204
10182
|
} else {
|
|
10205
10183
|
isAllString = false;
|
|
@@ -10217,7 +10195,7 @@ const mathmlBuilder$1 = (group, style) => {
|
|
|
10217
10195
|
if (isAllString) {
|
|
10218
10196
|
// Write a single TextNode instead of multiple nested tags.
|
|
10219
10197
|
const word = expression.map((node) => node.toText()).join("");
|
|
10220
|
-
expression = [new
|
|
10198
|
+
expression = [new TextNode(word)];
|
|
10221
10199
|
} else if (
|
|
10222
10200
|
expression.length === 1
|
|
10223
10201
|
&& ["mover", "munder"].includes(expression[0].type) &&
|
|
@@ -10225,41 +10203,41 @@ const mathmlBuilder$1 = (group, style) => {
|
|
|
10225
10203
|
) {
|
|
10226
10204
|
expression[0].children[0].type = "mi";
|
|
10227
10205
|
if (group.parentIsSupSub) {
|
|
10228
|
-
return new
|
|
10206
|
+
return new MathNode("mrow", expression)
|
|
10229
10207
|
} else {
|
|
10230
|
-
const operator = new
|
|
10231
|
-
return
|
|
10208
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
10209
|
+
return newDocumentFragment([expression[0], operator])
|
|
10232
10210
|
}
|
|
10233
10211
|
}
|
|
10234
10212
|
|
|
10235
10213
|
let wrapper;
|
|
10236
10214
|
if (isAllString) {
|
|
10237
|
-
wrapper = new
|
|
10215
|
+
wrapper = new MathNode("mi", expression);
|
|
10238
10216
|
if (expression[0].text.length === 1) {
|
|
10239
10217
|
wrapper.setAttribute("mathvariant", "normal");
|
|
10240
10218
|
}
|
|
10241
10219
|
} else {
|
|
10242
|
-
wrapper = new
|
|
10220
|
+
wrapper = new MathNode("mrow", expression);
|
|
10243
10221
|
}
|
|
10244
10222
|
|
|
10245
10223
|
if (!group.parentIsSupSub) {
|
|
10246
10224
|
// Append an <mo>⁡</mo>.
|
|
10247
10225
|
// ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
|
|
10248
|
-
const operator = new
|
|
10226
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
10249
10227
|
const fragment = [wrapper, operator];
|
|
10250
10228
|
if (group.needsLeadingSpace) {
|
|
10251
10229
|
// LaTeX gives operator spacing, but a <mi> gets ord spacing.
|
|
10252
10230
|
// So add a leading space.
|
|
10253
|
-
const space = new
|
|
10231
|
+
const space = new MathNode("mspace");
|
|
10254
10232
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
10255
10233
|
fragment.unshift(space);
|
|
10256
10234
|
}
|
|
10257
10235
|
if (!group.isFollowedByDelimiter) {
|
|
10258
|
-
const trail = new
|
|
10236
|
+
const trail = new MathNode("mspace");
|
|
10259
10237
|
trail.setAttribute("width", "0.1667em"); // thin space.
|
|
10260
10238
|
fragment.push(trail);
|
|
10261
10239
|
}
|
|
10262
|
-
return
|
|
10240
|
+
return newDocumentFragment(fragment)
|
|
10263
10241
|
}
|
|
10264
10242
|
|
|
10265
10243
|
return wrapper
|
|
@@ -10319,7 +10297,7 @@ defineFunction({
|
|
|
10319
10297
|
},
|
|
10320
10298
|
mathmlBuilder: (group, style) => {
|
|
10321
10299
|
const inner = buildExpression(group.body, style);
|
|
10322
|
-
return new
|
|
10300
|
+
return new MathNode("mphantom", inner);
|
|
10323
10301
|
}
|
|
10324
10302
|
});
|
|
10325
10303
|
|
|
@@ -10340,8 +10318,8 @@ defineFunction({
|
|
|
10340
10318
|
},
|
|
10341
10319
|
mathmlBuilder: (group, style) => {
|
|
10342
10320
|
const inner = buildExpression(ordargument(group.body), style);
|
|
10343
|
-
const phantom = new
|
|
10344
|
-
const node = new
|
|
10321
|
+
const phantom = new MathNode("mphantom", inner);
|
|
10322
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
10345
10323
|
node.setAttribute("height", "0px");
|
|
10346
10324
|
node.setAttribute("depth", "0px");
|
|
10347
10325
|
return node;
|
|
@@ -10365,8 +10343,8 @@ defineFunction({
|
|
|
10365
10343
|
},
|
|
10366
10344
|
mathmlBuilder: (group, style) => {
|
|
10367
10345
|
const inner = buildExpression(ordargument(group.body), style);
|
|
10368
|
-
const phantom = new
|
|
10369
|
-
const node = new
|
|
10346
|
+
const phantom = new MathNode("mphantom", inner);
|
|
10347
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
10370
10348
|
node.setAttribute("width", "0px");
|
|
10371
10349
|
return node;
|
|
10372
10350
|
}
|
|
@@ -10403,7 +10381,7 @@ defineFunction({
|
|
|
10403
10381
|
|
|
10404
10382
|
const mathmlBuilder = (group, style) => {
|
|
10405
10383
|
const newStyle = style.withLevel(StyleLevel.TEXT);
|
|
10406
|
-
const node = new
|
|
10384
|
+
const node = new MathNode("mpadded", [buildGroup$1(group.body, newStyle)]);
|
|
10407
10385
|
const dy = calculateSize(group.dy, style);
|
|
10408
10386
|
node.setAttribute("voffset", dy.number + dy.unit);
|
|
10409
10387
|
// Add padding, which acts to increase height in Chromium.
|
|
@@ -10551,7 +10529,7 @@ defineFunction({
|
|
|
10551
10529
|
: { number: 0, unit: "em" };
|
|
10552
10530
|
const color = (style.color && style.getColor()) || "black";
|
|
10553
10531
|
|
|
10554
|
-
const rule = new
|
|
10532
|
+
const rule = new MathNode("mspace");
|
|
10555
10533
|
if (width.number > 0 && height.number > 0) {
|
|
10556
10534
|
rule.setAttribute("mathbackground", color);
|
|
10557
10535
|
}
|
|
@@ -10559,7 +10537,7 @@ defineFunction({
|
|
|
10559
10537
|
rule.setAttribute("height", height.number + height.unit);
|
|
10560
10538
|
if (shift.number === 0) { return rule }
|
|
10561
10539
|
|
|
10562
|
-
const wrapper = new
|
|
10540
|
+
const wrapper = new MathNode("mpadded", [rule]);
|
|
10563
10541
|
if (shift.number >= 0) {
|
|
10564
10542
|
wrapper.setAttribute("height", "+" + shift.number + shift.unit);
|
|
10565
10543
|
} else {
|
|
@@ -10631,8 +10609,8 @@ defineFunction({
|
|
|
10631
10609
|
const numerator = group.numerator.split('').map(c => unicodeNumSups[c]).join('');
|
|
10632
10610
|
const denominator = group.denominator.split('').map(c => unicodeNumSubs[c]).join('');
|
|
10633
10611
|
// Use a fraction slash.
|
|
10634
|
-
const text = new
|
|
10635
|
-
return new
|
|
10612
|
+
const text = new TextNode(numerator + "\u2044" + denominator, group.mode, style);
|
|
10613
|
+
return new MathNode("mn", [text], ["special-fraction"])
|
|
10636
10614
|
}
|
|
10637
10615
|
});
|
|
10638
10616
|
|
|
@@ -10745,7 +10723,7 @@ defineFunction({
|
|
|
10745
10723
|
};
|
|
10746
10724
|
},
|
|
10747
10725
|
mathmlBuilder: (group, style) => {
|
|
10748
|
-
const node = new
|
|
10726
|
+
const node = new MathNode("mpadded", [buildGroup$1(group.body, style)]);
|
|
10749
10727
|
|
|
10750
10728
|
if (group.smashHeight) {
|
|
10751
10729
|
node.setAttribute("height", "0px");
|
|
@@ -10798,11 +10776,11 @@ defineFunction({
|
|
|
10798
10776
|
mathmlBuilder(group, style) {
|
|
10799
10777
|
const { body, index } = group;
|
|
10800
10778
|
return index
|
|
10801
|
-
? new
|
|
10779
|
+
? new MathNode("mroot", [
|
|
10802
10780
|
buildGroup$1(body, style),
|
|
10803
10781
|
buildGroup$1(index, style.incrementLevel())
|
|
10804
10782
|
])
|
|
10805
|
-
: new
|
|
10783
|
+
: new MathNode("msqrt", [buildGroup$1(body, style)]);
|
|
10806
10784
|
}
|
|
10807
10785
|
});
|
|
10808
10786
|
|
|
@@ -11001,26 +10979,26 @@ defineFunctionBuilders({
|
|
|
11001
10979
|
}
|
|
11002
10980
|
}
|
|
11003
10981
|
|
|
11004
|
-
let node = new
|
|
10982
|
+
let node = new MathNode(nodeType, children);
|
|
11005
10983
|
if (appendApplyFunction) {
|
|
11006
10984
|
// Append an <mo>⁡</mo>.
|
|
11007
10985
|
// ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
|
|
11008
|
-
const operator = new
|
|
10986
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
11009
10987
|
if (needsLeadingSpace) {
|
|
11010
|
-
const space = new
|
|
10988
|
+
const space = new MathNode("mspace");
|
|
11011
10989
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
11012
|
-
node =
|
|
10990
|
+
node = newDocumentFragment([space, node, operator]);
|
|
11013
10991
|
} else {
|
|
11014
|
-
node =
|
|
10992
|
+
node = newDocumentFragment([node, operator]);
|
|
11015
10993
|
}
|
|
11016
10994
|
if (appendSpace) {
|
|
11017
|
-
const space = new
|
|
10995
|
+
const space = new MathNode("mspace");
|
|
11018
10996
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
11019
10997
|
node.children.push(space);
|
|
11020
10998
|
}
|
|
11021
10999
|
} else if (symbolRegEx.test(nodeType)) {
|
|
11022
11000
|
// Wrap in a <mrow>. Otherwise Firefox stretchy parens will not stretch to include limits.
|
|
11023
|
-
node = new
|
|
11001
|
+
node = new MathNode("mrow", [node]);
|
|
11024
11002
|
}
|
|
11025
11003
|
|
|
11026
11004
|
return node
|
|
@@ -11045,7 +11023,7 @@ const isArrow = str => {
|
|
|
11045
11023
|
defineFunctionBuilders({
|
|
11046
11024
|
type: "atom",
|
|
11047
11025
|
mathmlBuilder(group, style) {
|
|
11048
|
-
const node = new
|
|
11026
|
+
const node = new MathNode("mo", [makeText(group.text, group.mode)]);
|
|
11049
11027
|
if (group.family === "punct") {
|
|
11050
11028
|
node.setAttribute("separator", "true");
|
|
11051
11029
|
} else if (group.family === "open" || group.family === "close") {
|
|
@@ -11075,10 +11053,10 @@ defineFunctionBuilders({
|
|
|
11075
11053
|
} else if (group.needsSpacing) {
|
|
11076
11054
|
// Fix a MathML bug that occurs when a <mo> is between two <mtext> elements.
|
|
11077
11055
|
if (group.family === "bin") {
|
|
11078
|
-
return new
|
|
11056
|
+
return new MathNode("mrow", [padding(0.222), node, padding(0.222)])
|
|
11079
11057
|
} else {
|
|
11080
11058
|
// REL spacing
|
|
11081
|
-
return new
|
|
11059
|
+
return new MathNode("mrow", [padding(0.2778), node, padding(0.2778)])
|
|
11082
11060
|
}
|
|
11083
11061
|
}
|
|
11084
11062
|
return node;
|
|
@@ -11419,8 +11397,8 @@ const primes = new Set(["\\prime", "\\dprime", "\\trprime", "\\qprime",
|
|
|
11419
11397
|
"\\backprime", "\\backdprime", "\\backtrprime"]);
|
|
11420
11398
|
|
|
11421
11399
|
const italicNumber = (text, variant, tag) => {
|
|
11422
|
-
const mn = new
|
|
11423
|
-
const wrapper = new
|
|
11400
|
+
const mn = new MathNode(tag, [text]);
|
|
11401
|
+
const wrapper = new MathNode("mstyle", [mn]);
|
|
11424
11402
|
wrapper.style["font-style"] = "italic";
|
|
11425
11403
|
wrapper.style["font-family"] = "Cambria, 'Times New Roman', serif";
|
|
11426
11404
|
if (variant === "bold-italic") { wrapper.style["font-weight"] = "bold"; }
|
|
@@ -11437,17 +11415,17 @@ defineFunctionBuilders({
|
|
|
11437
11415
|
const variant = getVariant(group, style) || defaultVariant;
|
|
11438
11416
|
if (variant === "script") {
|
|
11439
11417
|
text.text = variantChar(text.text, variant);
|
|
11440
|
-
return new
|
|
11418
|
+
return new MathNode("mi", [text], [style.font])
|
|
11441
11419
|
} else if (variant !== "italic") {
|
|
11442
11420
|
text.text = variantChar(text.text, variant);
|
|
11443
11421
|
}
|
|
11444
|
-
let node = new
|
|
11422
|
+
let node = new MathNode("mi", [text]);
|
|
11445
11423
|
// TODO: Handle U+1D49C - U+1D4CF per https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
11446
11424
|
if (variant === "normal") {
|
|
11447
11425
|
node.setAttribute("mathvariant", "normal");
|
|
11448
11426
|
if (text.text.length === 1) {
|
|
11449
11427
|
// A Firefox bug will apply spacing here, but there should be none. Fix it.
|
|
11450
|
-
node = new
|
|
11428
|
+
node = new MathNode("mpadded", [node]);
|
|
11451
11429
|
node.setAttribute("lspace", "0");
|
|
11452
11430
|
}
|
|
11453
11431
|
}
|
|
@@ -11478,15 +11456,15 @@ defineFunctionBuilders({
|
|
|
11478
11456
|
if (variant !== "normal") {
|
|
11479
11457
|
text.text = text.text.split("").map(c => variantChar(c, variant)).join("");
|
|
11480
11458
|
}
|
|
11481
|
-
node = new
|
|
11459
|
+
node = new MathNode(tag, [text]);
|
|
11482
11460
|
}
|
|
11483
11461
|
} else if (group.mode === "text") {
|
|
11484
11462
|
if (variant !== "normal") {
|
|
11485
11463
|
text.text = variantChar(text.text, variant);
|
|
11486
11464
|
}
|
|
11487
|
-
node = new
|
|
11465
|
+
node = new MathNode("mtext", [text]);
|
|
11488
11466
|
} else if (primes.has(group.text)) {
|
|
11489
|
-
node = new
|
|
11467
|
+
node = new MathNode("mo", [text]);
|
|
11490
11468
|
// TODO: If/when Chromium uses ssty variant for prime, remove the next line.
|
|
11491
11469
|
node.classes.push("tml-prime");
|
|
11492
11470
|
} else {
|
|
@@ -11494,7 +11472,7 @@ defineFunctionBuilders({
|
|
|
11494
11472
|
if (variant !== "italic") {
|
|
11495
11473
|
text.text = variantChar(text.text, variant);
|
|
11496
11474
|
}
|
|
11497
|
-
node = new
|
|
11475
|
+
node = new MathNode("mi", [text]);
|
|
11498
11476
|
if (text.text === origText && latinRegEx.test(origText)) {
|
|
11499
11477
|
node.setAttribute("mathvariant", "italic");
|
|
11500
11478
|
}
|
|
@@ -11537,11 +11515,11 @@ defineFunctionBuilders({
|
|
|
11537
11515
|
// Firefox does not render a space in a <mtext> </mtext>. So write a no-break space.
|
|
11538
11516
|
// TODO: If Firefox fixes that bug, uncomment the next line and write ch into the node.
|
|
11539
11517
|
//const ch = (regularSpace[group.text].className === "nobreak") ? "\u00a0" : " "
|
|
11540
|
-
node = new
|
|
11518
|
+
node = new MathNode("mtext", [new TextNode("\u00a0")]);
|
|
11541
11519
|
} else if (Object.prototype.hasOwnProperty.call(cssSpace, group.text)) {
|
|
11542
11520
|
// MathML 3.0 calls for nobreak to occur in an <mo>, not an <mtext>
|
|
11543
11521
|
// Ref: https://www.w3.org/Math/draft-spec/mathml.html#chapter3_presm.lbattrs
|
|
11544
|
-
node = new
|
|
11522
|
+
node = new MathNode("mo");
|
|
11545
11523
|
if (group.text === "\\nobreak") {
|
|
11546
11524
|
node.setAttribute("linebreak", "nobreak");
|
|
11547
11525
|
}
|
|
@@ -11656,10 +11634,10 @@ defineFunction({
|
|
|
11656
11634
|
},
|
|
11657
11635
|
mathmlBuilder(group, style) {
|
|
11658
11636
|
// Use a math table to create vertically centered content.
|
|
11659
|
-
const mtd = new
|
|
11637
|
+
const mtd = new MathNode("mtd", [buildGroup$1(group.body, style)]);
|
|
11660
11638
|
mtd.style.padding = "0";
|
|
11661
|
-
const mtr = new
|
|
11662
|
-
return new
|
|
11639
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
11640
|
+
return new MathNode("mtable", [mtr])
|
|
11663
11641
|
}
|
|
11664
11642
|
});
|
|
11665
11643
|
|
|
@@ -11678,8 +11656,8 @@ defineFunction({
|
|
|
11678
11656
|
throw new ParseError("\\verb ended by end of line instead of matching delimiter");
|
|
11679
11657
|
},
|
|
11680
11658
|
mathmlBuilder(group, style) {
|
|
11681
|
-
const text = new
|
|
11682
|
-
const node = new
|
|
11659
|
+
const text = new TextNode(makeVerb(group));
|
|
11660
|
+
const node = new MathNode("mtext", [text]);
|
|
11683
11661
|
node.setAttribute("mathvariant", "monospace");
|
|
11684
11662
|
return node;
|
|
11685
11663
|
}
|
|
@@ -14011,7 +13989,7 @@ class Style {
|
|
|
14011
13989
|
* https://mit-license.org/
|
|
14012
13990
|
*/
|
|
14013
13991
|
|
|
14014
|
-
const version = "0.
|
|
13992
|
+
const version = "0.12.01";
|
|
14015
13993
|
|
|
14016
13994
|
function postProcess(block) {
|
|
14017
13995
|
const labelMap = {};
|