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.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 + "'")
|
|
@@ -2807,31 +2786,31 @@ const calculateSize = function(sizeValue, style) {
|
|
|
2807
2786
|
|
|
2808
2787
|
// Helper functions
|
|
2809
2788
|
|
|
2810
|
-
const padding
|
|
2811
|
-
const node = new
|
|
2789
|
+
const padding = width => {
|
|
2790
|
+
const node = new MathNode("mspace");
|
|
2812
2791
|
node.setAttribute("width", width + "em");
|
|
2813
2792
|
return node
|
|
2814
2793
|
};
|
|
2815
2794
|
|
|
2816
2795
|
const paddedNode = (group, lspace = 0.3, rspace = 0, mustSmash = false) => {
|
|
2817
|
-
if (group == null && rspace === 0) { return padding
|
|
2796
|
+
if (group == null && rspace === 0) { return padding(lspace) }
|
|
2818
2797
|
const row = group ? [group] : [];
|
|
2819
|
-
if (lspace !== 0) { row.unshift(padding
|
|
2820
|
-
if (rspace > 0) { row.push(padding
|
|
2798
|
+
if (lspace !== 0) { row.unshift(padding(lspace)); }
|
|
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
|
|
@@ -2949,9 +2928,9 @@ defineFunction({
|
|
|
2949
2928
|
const node = munderoverNode(group.name, group.body, group.below, style);
|
|
2950
2929
|
// Create operator spacing for a relation.
|
|
2951
2930
|
const row = [node];
|
|
2952
|
-
row.unshift(padding
|
|
2953
|
-
row.push(padding
|
|
2954
|
-
return new
|
|
2931
|
+
row.unshift(padding(0.2778));
|
|
2932
|
+
row.push(padding(0.2778));
|
|
2933
|
+
return new MathNode("mrow", row)
|
|
2955
2934
|
}
|
|
2956
2935
|
});
|
|
2957
2936
|
|
|
@@ -3004,23 +2983,23 @@ 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
|
-
[padding
|
|
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
|
-
[padding
|
|
3002
|
+
[padding(0.2778), raiseNode, botArrow, padding(0.2778)]
|
|
3024
3003
|
);
|
|
3025
3004
|
}
|
|
3026
3005
|
|
|
@@ -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) {
|
|
@@ -7908,6 +7886,9 @@ const sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0];
|
|
|
7908
7886
|
|
|
7909
7887
|
// Delimiter functions
|
|
7910
7888
|
function checkDelimiter(delim, context) {
|
|
7889
|
+
if (delim.type === "ordgroup" && delim.body.length === 1) {
|
|
7890
|
+
delim = delim.body[0]; // Unwrap the braces
|
|
7891
|
+
}
|
|
7911
7892
|
const symDelim = checkSymbolNodeType(delim);
|
|
7912
7893
|
if (symDelim && delimiters.includes(symDelim.text)) {
|
|
7913
7894
|
// If a character is not in the MathML operator dictionary, it will not stretch.
|
|
@@ -7978,7 +7959,7 @@ defineFunction({
|
|
|
7978
7959
|
if (group.delim === ".") { group.delim = ""; }
|
|
7979
7960
|
children.push(makeText(group.delim, group.mode));
|
|
7980
7961
|
|
|
7981
|
-
const node = new
|
|
7962
|
+
const node = new MathNode("mo", children);
|
|
7982
7963
|
|
|
7983
7964
|
if (group.mclass === "mopen" || group.mclass === "mclose") {
|
|
7984
7965
|
// Only some of the delimsizing functions act as fences, and they
|
|
@@ -8072,7 +8053,7 @@ defineFunction({
|
|
|
8072
8053
|
const inner = buildExpression(group.body, style);
|
|
8073
8054
|
|
|
8074
8055
|
if (group.left === ".") { group.left = ""; }
|
|
8075
|
-
const leftNode = new
|
|
8056
|
+
const leftNode = new MathNode("mo", [makeText(group.left, group.mode)]);
|
|
8076
8057
|
leftNode.setAttribute("fence", "true");
|
|
8077
8058
|
leftNode.setAttribute("form", "prefix");
|
|
8078
8059
|
if (group.left === "/" || group.left === "\u005C" || group.left.indexOf("arrow") > -1) {
|
|
@@ -8081,7 +8062,7 @@ defineFunction({
|
|
|
8081
8062
|
inner.unshift(leftNode);
|
|
8082
8063
|
|
|
8083
8064
|
if (group.right === ".") { group.right = ""; }
|
|
8084
|
-
const rightNode = new
|
|
8065
|
+
const rightNode = new MathNode("mo", [makeText(group.right, group.mode)]);
|
|
8085
8066
|
rightNode.setAttribute("fence", "true");
|
|
8086
8067
|
rightNode.setAttribute("form", "postfix");
|
|
8087
8068
|
if (group.right === "\u2216" || group.right.indexOf("arrow") > -1) {
|
|
@@ -8123,7 +8104,7 @@ defineFunction({
|
|
|
8123
8104
|
},
|
|
8124
8105
|
mathmlBuilder: (group, style) => {
|
|
8125
8106
|
const textNode = makeText(group.delim, group.mode);
|
|
8126
|
-
const middleNode = new
|
|
8107
|
+
const middleNode = new MathNode("mo", [textNode]);
|
|
8127
8108
|
middleNode.setAttribute("fence", "true");
|
|
8128
8109
|
if (group.delim.indexOf("arrow") > -1) {
|
|
8129
8110
|
middleNode.setAttribute("stretchy", "true");
|
|
@@ -8139,26 +8120,9 @@ defineFunction({
|
|
|
8139
8120
|
}
|
|
8140
8121
|
});
|
|
8141
8122
|
|
|
8142
|
-
const padding = _ => {
|
|
8143
|
-
const node = new mathMLTree.MathNode("mspace");
|
|
8144
|
-
node.setAttribute("width", "3pt");
|
|
8145
|
-
return node
|
|
8146
|
-
};
|
|
8147
|
-
|
|
8148
8123
|
const mathmlBuilder$7 = (group, style) => {
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
// MathML core does not support +width attribute in <mpadded>.
|
|
8152
|
-
// Firefox does not reliably add side padding.
|
|
8153
|
-
// Insert <mspace>
|
|
8154
|
-
node = new mathMLTree.MathNode("mrow", [
|
|
8155
|
-
padding(),
|
|
8156
|
-
buildGroup$1(group.body, style),
|
|
8157
|
-
padding()
|
|
8158
|
-
]);
|
|
8159
|
-
} else {
|
|
8160
|
-
node = new mathMLTree.MathNode("menclose", [buildGroup$1(group.body, style)]);
|
|
8161
|
-
}
|
|
8124
|
+
const tag = group.label === "\\boxed" ? "mrow" : "menclose";
|
|
8125
|
+
const node = new MathNode(tag, [buildGroup$1(group.body, style)]);
|
|
8162
8126
|
switch (group.label) {
|
|
8163
8127
|
case "\\overline":
|
|
8164
8128
|
node.setAttribute("notation", "top"); // for Firefox & WebKit
|
|
@@ -8170,15 +8134,15 @@ const mathmlBuilder$7 = (group, style) => {
|
|
|
8170
8134
|
break
|
|
8171
8135
|
case "\\cancel":
|
|
8172
8136
|
node.setAttribute("notation", "updiagonalstrike");
|
|
8173
|
-
node.children.push(new
|
|
8137
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "upstrike"]));
|
|
8174
8138
|
break
|
|
8175
8139
|
case "\\bcancel":
|
|
8176
8140
|
node.setAttribute("notation", "downdiagonalstrike");
|
|
8177
|
-
node.children.push(new
|
|
8141
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "downstrike"]));
|
|
8178
8142
|
break
|
|
8179
8143
|
case "\\sout":
|
|
8180
8144
|
node.setAttribute("notation", "horizontalstrike");
|
|
8181
|
-
node.children.push(new
|
|
8145
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "sout"]));
|
|
8182
8146
|
break
|
|
8183
8147
|
case "\\xcancel":
|
|
8184
8148
|
node.setAttribute("notation", "updiagonalstrike downdiagonalstrike");
|
|
@@ -8187,17 +8151,17 @@ const mathmlBuilder$7 = (group, style) => {
|
|
|
8187
8151
|
case "\\longdiv":
|
|
8188
8152
|
node.setAttribute("notation", "longdiv");
|
|
8189
8153
|
node.classes.push("longdiv-top");
|
|
8190
|
-
node.children.push(new
|
|
8154
|
+
node.children.push(new MathNode("mrow", [], ["longdiv-arc"]));
|
|
8191
8155
|
break
|
|
8192
8156
|
case "\\phase":
|
|
8193
8157
|
node.setAttribute("notation", "phasorangle");
|
|
8194
8158
|
node.classes.push("phasor-bottom");
|
|
8195
|
-
node.children.push(new
|
|
8159
|
+
node.children.push(new MathNode("mrow", [], ["phasor-angle"]));
|
|
8196
8160
|
break
|
|
8197
8161
|
case "\\textcircled":
|
|
8198
8162
|
node.setAttribute("notation", "circle");
|
|
8199
8163
|
node.classes.push("circle-pad");
|
|
8200
|
-
node.children.push(new
|
|
8164
|
+
node.children.push(new MathNode("mrow", [], ["textcircle"]));
|
|
8201
8165
|
break
|
|
8202
8166
|
case "\\angl":
|
|
8203
8167
|
node.setAttribute("notation", "actuarial");
|
|
@@ -8205,8 +8169,7 @@ const mathmlBuilder$7 = (group, style) => {
|
|
|
8205
8169
|
break
|
|
8206
8170
|
case "\\boxed":
|
|
8207
8171
|
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
|
|
8208
|
-
node.
|
|
8209
|
-
node.style.padding = "padding: 3pt 0 3pt 0";
|
|
8172
|
+
node.style.padding = "3pt";
|
|
8210
8173
|
node.style.border = "1px solid";
|
|
8211
8174
|
node.setAttribute("scriptlevel", "0");
|
|
8212
8175
|
node.setAttribute("displaystyle", "true");
|
|
@@ -8223,12 +8186,10 @@ const mathmlBuilder$7 = (group, style) => {
|
|
|
8223
8186
|
//const fboxsep = 3; // 3 pt from LaTeX source2e
|
|
8224
8187
|
//node.setAttribute("height", `+${2 * fboxsep}pt`)
|
|
8225
8188
|
//node.setAttribute("voffset", `${fboxsep}pt`)
|
|
8226
|
-
|
|
8227
|
-
|
|
8189
|
+
node.style.padding = "3pt";
|
|
8228
8190
|
if (group.label === "\\fcolorbox") {
|
|
8229
|
-
style.border = "0.0667em solid " + String(group.borderColor);
|
|
8191
|
+
node.style.border = "0.0667em solid " + String(group.borderColor);
|
|
8230
8192
|
}
|
|
8231
|
-
node.style = style;
|
|
8232
8193
|
break
|
|
8233
8194
|
}
|
|
8234
8195
|
}
|
|
@@ -8451,7 +8412,7 @@ defineFunction({
|
|
|
8451
8412
|
};
|
|
8452
8413
|
},
|
|
8453
8414
|
mathmlBuilder(group, style) {
|
|
8454
|
-
return new
|
|
8415
|
+
return new MathNode("mrow");
|
|
8455
8416
|
}
|
|
8456
8417
|
});
|
|
8457
8418
|
|
|
@@ -8468,7 +8429,7 @@ defineFunction({
|
|
|
8468
8429
|
};
|
|
8469
8430
|
},
|
|
8470
8431
|
mathmlBuilder(group, style) {
|
|
8471
|
-
return new
|
|
8432
|
+
return new MathNode("mrow");
|
|
8472
8433
|
}
|
|
8473
8434
|
});
|
|
8474
8435
|
|
|
@@ -8511,7 +8472,7 @@ const mathmlBuilder$6 = (group, style) => {
|
|
|
8511
8472
|
: mathGroup.children[i].children[0].text;
|
|
8512
8473
|
}
|
|
8513
8474
|
// Wrap in a <mpadded> to prevent the same Firefox bug.
|
|
8514
|
-
const mpadded = new
|
|
8475
|
+
const mpadded = new MathNode("mpadded", [mi]);
|
|
8515
8476
|
mpadded.setAttribute("lspace", "0");
|
|
8516
8477
|
return mpadded
|
|
8517
8478
|
}
|
|
@@ -8537,8 +8498,8 @@ const mathmlBuilder$6 = (group, style) => {
|
|
|
8537
8498
|
// Ref: https://bugs.webkit.org/show_bug.cgi?id=129097
|
|
8538
8499
|
// We insert a text node that contains a zero-width space and wrap in an mrow.
|
|
8539
8500
|
// TODO: Get rid of this <mi> workaround when the Firefox bug is fixed.
|
|
8540
|
-
const bogus = new
|
|
8541
|
-
return new
|
|
8501
|
+
const bogus = new MathNode("mtext", new TextNode("\u200b"));
|
|
8502
|
+
return new MathNode("mrow", [bogus, mi])
|
|
8542
8503
|
}
|
|
8543
8504
|
return mi
|
|
8544
8505
|
};
|
|
@@ -8649,7 +8610,7 @@ const mathmlBuilder$5 = (group, style) => {
|
|
|
8649
8610
|
denom.setAttribute("scriptlevel", "2");
|
|
8650
8611
|
}
|
|
8651
8612
|
|
|
8652
|
-
let node = new
|
|
8613
|
+
let node = new MathNode("mfrac", [numer, denom]);
|
|
8653
8614
|
|
|
8654
8615
|
if (!group.hasBarLine) {
|
|
8655
8616
|
node.setAttribute("linethickness", "0px");
|
|
@@ -8662,8 +8623,8 @@ const mathmlBuilder$5 = (group, style) => {
|
|
|
8662
8623
|
const withDelims = [];
|
|
8663
8624
|
|
|
8664
8625
|
if (group.leftDelim != null) {
|
|
8665
|
-
const leftOp = new
|
|
8666
|
-
new
|
|
8626
|
+
const leftOp = new MathNode("mo", [
|
|
8627
|
+
new TextNode(group.leftDelim.replace("\\", ""))
|
|
8667
8628
|
]);
|
|
8668
8629
|
leftOp.setAttribute("fence", "true");
|
|
8669
8630
|
withDelims.push(leftOp);
|
|
@@ -8672,8 +8633,8 @@ const mathmlBuilder$5 = (group, style) => {
|
|
|
8672
8633
|
withDelims.push(node);
|
|
8673
8634
|
|
|
8674
8635
|
if (group.rightDelim != null) {
|
|
8675
|
-
const rightOp = new
|
|
8676
|
-
new
|
|
8636
|
+
const rightOp = new MathNode("mo", [
|
|
8637
|
+
new TextNode(group.rightDelim.replace("\\", ""))
|
|
8677
8638
|
]);
|
|
8678
8639
|
rightOp.setAttribute("fence", "true");
|
|
8679
8640
|
withDelims.push(rightOp);
|
|
@@ -8683,7 +8644,7 @@ const mathmlBuilder$5 = (group, style) => {
|
|
|
8683
8644
|
}
|
|
8684
8645
|
|
|
8685
8646
|
if (group.scriptLevel !== "auto") {
|
|
8686
|
-
node = new
|
|
8647
|
+
node = new MathNode("mstyle", [node]);
|
|
8687
8648
|
node.setAttribute("displaystyle", String(group.scriptLevel === "display"));
|
|
8688
8649
|
node.setAttribute("scriptlevel", scriptLevel[group.scriptLevel]);
|
|
8689
8650
|
}
|
|
@@ -8986,9 +8947,9 @@ defineFunction({
|
|
|
8986
8947
|
});
|
|
8987
8948
|
|
|
8988
8949
|
const mathmlBuilder$4 = (group, style) => {
|
|
8989
|
-
const accentNode =
|
|
8950
|
+
const accentNode = mathMLnode(group.label);
|
|
8990
8951
|
accentNode.style["math-depth"] = 0;
|
|
8991
|
-
return new
|
|
8952
|
+
return new MathNode(group.isOver ? "mover" : "munder", [
|
|
8992
8953
|
buildGroup$1(group.base, style),
|
|
8993
8954
|
accentNode
|
|
8994
8955
|
]);
|
|
@@ -9224,7 +9185,7 @@ defineFunction({
|
|
|
9224
9185
|
const node = new Img(group.src, group.alt, graphicStyle);
|
|
9225
9186
|
node.height = height;
|
|
9226
9187
|
node.depth = depth;
|
|
9227
|
-
return new
|
|
9188
|
+
return new MathNode("mtext", [node])
|
|
9228
9189
|
}
|
|
9229
9190
|
});
|
|
9230
9191
|
|
|
@@ -9274,17 +9235,17 @@ defineFunction({
|
|
|
9274
9235
|
? spaceCharacter(dimension.number)
|
|
9275
9236
|
: "";
|
|
9276
9237
|
if (group.mode === "text" && ch.length > 0) {
|
|
9277
|
-
const character = new
|
|
9278
|
-
return new
|
|
9238
|
+
const character = new TextNode(ch);
|
|
9239
|
+
return new MathNode("mtext", [character]);
|
|
9279
9240
|
} else {
|
|
9280
9241
|
if (dimension.number >= 0) {
|
|
9281
|
-
const node = new
|
|
9242
|
+
const node = new MathNode("mspace");
|
|
9282
9243
|
node.setAttribute("width", dimension.number + dimension.unit);
|
|
9283
9244
|
return node
|
|
9284
9245
|
} else {
|
|
9285
9246
|
// Don't use <mspace> or <mpadded> because
|
|
9286
9247
|
// WebKit recognizes negative left margin only on a <mrow> element
|
|
9287
|
-
const node = new
|
|
9248
|
+
const node = new MathNode("mrow");
|
|
9288
9249
|
node.style.marginLeft = dimension.number + dimension.unit;
|
|
9289
9250
|
return node
|
|
9290
9251
|
}
|
|
@@ -9325,7 +9286,7 @@ defineFunction({
|
|
|
9325
9286
|
},
|
|
9326
9287
|
mathmlBuilder(group, style) {
|
|
9327
9288
|
// Return a no-width, no-ink element with an HTML id.
|
|
9328
|
-
const node = new
|
|
9289
|
+
const node = new MathNode("mrow", [], ["tml-label"]);
|
|
9329
9290
|
if (group.string.length > 0) {
|
|
9330
9291
|
node.setLabel(group.string);
|
|
9331
9292
|
}
|
|
@@ -9369,8 +9330,8 @@ defineFunction({
|
|
|
9369
9330
|
// We need an invisible strut with the same depth as the group.
|
|
9370
9331
|
// We can't just read the depth, so we use \vphantom methods.
|
|
9371
9332
|
const phantomInner = buildExpression(ordargument(group.body), style);
|
|
9372
|
-
const phantom = new
|
|
9373
|
-
strut = new
|
|
9333
|
+
const phantom = new MathNode("mphantom", phantomInner);
|
|
9334
|
+
strut = new MathNode("mpadded", [phantom]);
|
|
9374
9335
|
strut.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
9375
9336
|
}
|
|
9376
9337
|
|
|
@@ -9380,9 +9341,9 @@ defineFunction({
|
|
|
9380
9341
|
inner.style.position = "absolute";
|
|
9381
9342
|
inner.style.right = "0";
|
|
9382
9343
|
inner.style.bottom = `0`; // If we could have read the ink depth, it would go here.
|
|
9383
|
-
node = new
|
|
9344
|
+
node = new MathNode("mpadded", [strut, inner]);
|
|
9384
9345
|
} else {
|
|
9385
|
-
node = new
|
|
9346
|
+
node = new MathNode("mpadded", [inner]);
|
|
9386
9347
|
}
|
|
9387
9348
|
|
|
9388
9349
|
if (group.alignment === "rlap") {
|
|
@@ -9488,7 +9449,7 @@ function mathmlBuilder$3(group, style) {
|
|
|
9488
9449
|
const inner = buildExpression(group.body, style);
|
|
9489
9450
|
|
|
9490
9451
|
if (group.mclass === "minner") {
|
|
9491
|
-
node = new
|
|
9452
|
+
node = new MathNode("mpadded", inner);
|
|
9492
9453
|
} else if (group.mclass === "mord") {
|
|
9493
9454
|
if (group.isCharacterBox || inner[0].type === "mathord") {
|
|
9494
9455
|
node = inner[0];
|
|
@@ -9497,10 +9458,10 @@ function mathmlBuilder$3(group, style) {
|
|
|
9497
9458
|
node.setAttribute("mathvariant", "normal");
|
|
9498
9459
|
}
|
|
9499
9460
|
} else {
|
|
9500
|
-
node = new
|
|
9461
|
+
node = new MathNode("mi", inner);
|
|
9501
9462
|
}
|
|
9502
9463
|
} else {
|
|
9503
|
-
node = new
|
|
9464
|
+
node = new MathNode("mrow", inner);
|
|
9504
9465
|
if (group.mustPromote) {
|
|
9505
9466
|
node = inner[0];
|
|
9506
9467
|
node.type = "mo";
|
|
@@ -9508,7 +9469,7 @@ function mathmlBuilder$3(group, style) {
|
|
|
9508
9469
|
node.setAttribute("mathvariant", "italic");
|
|
9509
9470
|
}
|
|
9510
9471
|
} else {
|
|
9511
|
-
node = new
|
|
9472
|
+
node = new MathNode("mrow", inner);
|
|
9512
9473
|
}
|
|
9513
9474
|
|
|
9514
9475
|
// Set spacing based on what is the most likely adjacent atom type.
|
|
@@ -9518,17 +9479,17 @@ function mathmlBuilder$3(group, style) {
|
|
|
9518
9479
|
if (doSpacing ) {
|
|
9519
9480
|
if (group.mclass === "mbin") {
|
|
9520
9481
|
// medium space
|
|
9521
|
-
node.children.unshift(padding
|
|
9522
|
-
node.children.push(padding
|
|
9482
|
+
node.children.unshift(padding(0.2222));
|
|
9483
|
+
node.children.push(padding(0.2222));
|
|
9523
9484
|
} else if (group.mclass === "mrel") {
|
|
9524
9485
|
// thickspace
|
|
9525
|
-
node.children.unshift(padding
|
|
9526
|
-
node.children.push(padding
|
|
9486
|
+
node.children.unshift(padding(0.2778));
|
|
9487
|
+
node.children.push(padding(0.2778));
|
|
9527
9488
|
} else if (group.mclass === "mpunct") {
|
|
9528
|
-
node.children.push(padding
|
|
9489
|
+
node.children.push(padding(0.1667));
|
|
9529
9490
|
} else if (group.mclass === "minner") {
|
|
9530
|
-
node.children.unshift(padding
|
|
9531
|
-
node.children.push(padding
|
|
9491
|
+
node.children.unshift(padding(0.0556)); // 1 mu is the most likely option
|
|
9492
|
+
node.children.push(padding(0.0556));
|
|
9532
9493
|
}
|
|
9533
9494
|
}
|
|
9534
9495
|
} else {
|
|
@@ -9578,7 +9539,7 @@ defineFunction({
|
|
|
9578
9539
|
},
|
|
9579
9540
|
handler({ parser, funcName }, args) {
|
|
9580
9541
|
const body = args[0];
|
|
9581
|
-
const isCharacterBox =
|
|
9542
|
+
const isCharacterBox$1 = isCharacterBox(body);
|
|
9582
9543
|
// We should not wrap a <mo> around a <mi> or <mord>. That would be invalid MathML.
|
|
9583
9544
|
// In that case, we instead promote the text contents of the body to the parent.
|
|
9584
9545
|
let mustPromote = true;
|
|
@@ -9607,7 +9568,7 @@ defineFunction({
|
|
|
9607
9568
|
mode: parser.mode,
|
|
9608
9569
|
mclass: "m" + funcName.slice(5),
|
|
9609
9570
|
body: ordargument(mustPromote ? mord : body),
|
|
9610
|
-
isCharacterBox,
|
|
9571
|
+
isCharacterBox: isCharacterBox$1,
|
|
9611
9572
|
mustPromote
|
|
9612
9573
|
};
|
|
9613
9574
|
}
|
|
@@ -9644,7 +9605,7 @@ defineFunction({
|
|
|
9644
9605
|
mode: parser.mode,
|
|
9645
9606
|
mclass: binrelClass(args[0]),
|
|
9646
9607
|
body: ordargument(args[1]),
|
|
9647
|
-
isCharacterBox:
|
|
9608
|
+
isCharacterBox: isCharacterBox(args[1])
|
|
9648
9609
|
};
|
|
9649
9610
|
}
|
|
9650
9611
|
});
|
|
@@ -9758,8 +9719,8 @@ defineFunction({
|
|
|
9758
9719
|
mathmlBuilder(group, style) {
|
|
9759
9720
|
const base = buildGroup$1(group.base, style);
|
|
9760
9721
|
|
|
9761
|
-
const prescriptsNode = new
|
|
9762
|
-
const noneNode = new
|
|
9722
|
+
const prescriptsNode = new MathNode("mprescripts");
|
|
9723
|
+
const noneNode = new MathNode("none");
|
|
9763
9724
|
let children = [];
|
|
9764
9725
|
|
|
9765
9726
|
const preSub = buildGroup(group.prescripts.sub, style, noneNode);
|
|
@@ -9778,7 +9739,7 @@ defineFunction({
|
|
|
9778
9739
|
children = [base, prescriptsNode, preSub, preSup];
|
|
9779
9740
|
}
|
|
9780
9741
|
|
|
9781
|
-
return new
|
|
9742
|
+
return new MathNode("mmultiscripts", children);
|
|
9782
9743
|
}
|
|
9783
9744
|
});
|
|
9784
9745
|
|
|
@@ -9791,9 +9752,9 @@ defineFunction({
|
|
|
9791
9752
|
allowedInText: false
|
|
9792
9753
|
},
|
|
9793
9754
|
handler({ parser }, args) {
|
|
9794
|
-
const isCharacterBox =
|
|
9755
|
+
const isCharacterBox$1 = isCharacterBox(args[0]);
|
|
9795
9756
|
let body;
|
|
9796
|
-
if (isCharacterBox) {
|
|
9757
|
+
if (isCharacterBox$1) {
|
|
9797
9758
|
body = ordargument(args[0]);
|
|
9798
9759
|
if (body[0].text.charAt(0) === "\\") {
|
|
9799
9760
|
body[0].text = symbols.math[body[0].text].replace;
|
|
@@ -9811,7 +9772,7 @@ defineFunction({
|
|
|
9811
9772
|
type: "not",
|
|
9812
9773
|
mode: parser.mode,
|
|
9813
9774
|
body,
|
|
9814
|
-
isCharacterBox
|
|
9775
|
+
isCharacterBox: isCharacterBox$1
|
|
9815
9776
|
};
|
|
9816
9777
|
},
|
|
9817
9778
|
mathmlBuilder(group, style) {
|
|
@@ -10190,9 +10151,9 @@ const mathmlBuilder$1 = (group, style) => {
|
|
|
10190
10151
|
let isAllString = true; // default
|
|
10191
10152
|
for (let i = 0; i < expression.length; i++) {
|
|
10192
10153
|
let node = expression[i];
|
|
10193
|
-
if (node instanceof
|
|
10154
|
+
if (node instanceof MathNode) {
|
|
10194
10155
|
if ((node.type === "mrow" || node.type === "mpadded") && node.children.length === 1 &&
|
|
10195
|
-
node.children[0] instanceof
|
|
10156
|
+
node.children[0] instanceof MathNode) {
|
|
10196
10157
|
node = node.children[0];
|
|
10197
10158
|
}
|
|
10198
10159
|
switch (node.type) {
|
|
@@ -10209,14 +10170,14 @@ const mathmlBuilder$1 = (group, style) => {
|
|
|
10209
10170
|
if (ch === "") {
|
|
10210
10171
|
isAllString = false;
|
|
10211
10172
|
} else {
|
|
10212
|
-
expression[i] = new
|
|
10173
|
+
expression[i] = new MathNode("mtext", [new TextNode(ch)]);
|
|
10213
10174
|
}
|
|
10214
10175
|
}
|
|
10215
10176
|
}
|
|
10216
10177
|
break
|
|
10217
10178
|
case "mo": {
|
|
10218
10179
|
const child = node.children[0];
|
|
10219
|
-
if (node.children.length === 1 && child instanceof
|
|
10180
|
+
if (node.children.length === 1 && child instanceof TextNode) {
|
|
10220
10181
|
child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
|
|
10221
10182
|
} else {
|
|
10222
10183
|
isAllString = false;
|
|
@@ -10234,7 +10195,7 @@ const mathmlBuilder$1 = (group, style) => {
|
|
|
10234
10195
|
if (isAllString) {
|
|
10235
10196
|
// Write a single TextNode instead of multiple nested tags.
|
|
10236
10197
|
const word = expression.map((node) => node.toText()).join("");
|
|
10237
|
-
expression = [new
|
|
10198
|
+
expression = [new TextNode(word)];
|
|
10238
10199
|
} else if (
|
|
10239
10200
|
expression.length === 1
|
|
10240
10201
|
&& ["mover", "munder"].includes(expression[0].type) &&
|
|
@@ -10242,41 +10203,41 @@ const mathmlBuilder$1 = (group, style) => {
|
|
|
10242
10203
|
) {
|
|
10243
10204
|
expression[0].children[0].type = "mi";
|
|
10244
10205
|
if (group.parentIsSupSub) {
|
|
10245
|
-
return new
|
|
10206
|
+
return new MathNode("mrow", expression)
|
|
10246
10207
|
} else {
|
|
10247
|
-
const operator = new
|
|
10248
|
-
return
|
|
10208
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
10209
|
+
return newDocumentFragment([expression[0], operator])
|
|
10249
10210
|
}
|
|
10250
10211
|
}
|
|
10251
10212
|
|
|
10252
10213
|
let wrapper;
|
|
10253
10214
|
if (isAllString) {
|
|
10254
|
-
wrapper = new
|
|
10215
|
+
wrapper = new MathNode("mi", expression);
|
|
10255
10216
|
if (expression[0].text.length === 1) {
|
|
10256
10217
|
wrapper.setAttribute("mathvariant", "normal");
|
|
10257
10218
|
}
|
|
10258
10219
|
} else {
|
|
10259
|
-
wrapper = new
|
|
10220
|
+
wrapper = new MathNode("mrow", expression);
|
|
10260
10221
|
}
|
|
10261
10222
|
|
|
10262
10223
|
if (!group.parentIsSupSub) {
|
|
10263
10224
|
// Append an <mo>⁡</mo>.
|
|
10264
10225
|
// ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
|
|
10265
|
-
const operator = new
|
|
10226
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
10266
10227
|
const fragment = [wrapper, operator];
|
|
10267
10228
|
if (group.needsLeadingSpace) {
|
|
10268
10229
|
// LaTeX gives operator spacing, but a <mi> gets ord spacing.
|
|
10269
10230
|
// So add a leading space.
|
|
10270
|
-
const space = new
|
|
10231
|
+
const space = new MathNode("mspace");
|
|
10271
10232
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
10272
10233
|
fragment.unshift(space);
|
|
10273
10234
|
}
|
|
10274
10235
|
if (!group.isFollowedByDelimiter) {
|
|
10275
|
-
const trail = new
|
|
10236
|
+
const trail = new MathNode("mspace");
|
|
10276
10237
|
trail.setAttribute("width", "0.1667em"); // thin space.
|
|
10277
10238
|
fragment.push(trail);
|
|
10278
10239
|
}
|
|
10279
|
-
return
|
|
10240
|
+
return newDocumentFragment(fragment)
|
|
10280
10241
|
}
|
|
10281
10242
|
|
|
10282
10243
|
return wrapper
|
|
@@ -10336,7 +10297,7 @@ defineFunction({
|
|
|
10336
10297
|
},
|
|
10337
10298
|
mathmlBuilder: (group, style) => {
|
|
10338
10299
|
const inner = buildExpression(group.body, style);
|
|
10339
|
-
return new
|
|
10300
|
+
return new MathNode("mphantom", inner);
|
|
10340
10301
|
}
|
|
10341
10302
|
});
|
|
10342
10303
|
|
|
@@ -10357,8 +10318,8 @@ defineFunction({
|
|
|
10357
10318
|
},
|
|
10358
10319
|
mathmlBuilder: (group, style) => {
|
|
10359
10320
|
const inner = buildExpression(ordargument(group.body), style);
|
|
10360
|
-
const phantom = new
|
|
10361
|
-
const node = new
|
|
10321
|
+
const phantom = new MathNode("mphantom", inner);
|
|
10322
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
10362
10323
|
node.setAttribute("height", "0px");
|
|
10363
10324
|
node.setAttribute("depth", "0px");
|
|
10364
10325
|
return node;
|
|
@@ -10382,8 +10343,8 @@ defineFunction({
|
|
|
10382
10343
|
},
|
|
10383
10344
|
mathmlBuilder: (group, style) => {
|
|
10384
10345
|
const inner = buildExpression(ordargument(group.body), style);
|
|
10385
|
-
const phantom = new
|
|
10386
|
-
const node = new
|
|
10346
|
+
const phantom = new MathNode("mphantom", inner);
|
|
10347
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
10387
10348
|
node.setAttribute("width", "0px");
|
|
10388
10349
|
return node;
|
|
10389
10350
|
}
|
|
@@ -10420,7 +10381,7 @@ defineFunction({
|
|
|
10420
10381
|
|
|
10421
10382
|
const mathmlBuilder = (group, style) => {
|
|
10422
10383
|
const newStyle = style.withLevel(StyleLevel.TEXT);
|
|
10423
|
-
const node = new
|
|
10384
|
+
const node = new MathNode("mpadded", [buildGroup$1(group.body, newStyle)]);
|
|
10424
10385
|
const dy = calculateSize(group.dy, style);
|
|
10425
10386
|
node.setAttribute("voffset", dy.number + dy.unit);
|
|
10426
10387
|
// Add padding, which acts to increase height in Chromium.
|
|
@@ -10568,7 +10529,7 @@ defineFunction({
|
|
|
10568
10529
|
: { number: 0, unit: "em" };
|
|
10569
10530
|
const color = (style.color && style.getColor()) || "black";
|
|
10570
10531
|
|
|
10571
|
-
const rule = new
|
|
10532
|
+
const rule = new MathNode("mspace");
|
|
10572
10533
|
if (width.number > 0 && height.number > 0) {
|
|
10573
10534
|
rule.setAttribute("mathbackground", color);
|
|
10574
10535
|
}
|
|
@@ -10576,7 +10537,7 @@ defineFunction({
|
|
|
10576
10537
|
rule.setAttribute("height", height.number + height.unit);
|
|
10577
10538
|
if (shift.number === 0) { return rule }
|
|
10578
10539
|
|
|
10579
|
-
const wrapper = new
|
|
10540
|
+
const wrapper = new MathNode("mpadded", [rule]);
|
|
10580
10541
|
if (shift.number >= 0) {
|
|
10581
10542
|
wrapper.setAttribute("height", "+" + shift.number + shift.unit);
|
|
10582
10543
|
} else {
|
|
@@ -10648,8 +10609,8 @@ defineFunction({
|
|
|
10648
10609
|
const numerator = group.numerator.split('').map(c => unicodeNumSups[c]).join('');
|
|
10649
10610
|
const denominator = group.denominator.split('').map(c => unicodeNumSubs[c]).join('');
|
|
10650
10611
|
// Use a fraction slash.
|
|
10651
|
-
const text = new
|
|
10652
|
-
return new
|
|
10612
|
+
const text = new TextNode(numerator + "\u2044" + denominator, group.mode, style);
|
|
10613
|
+
return new MathNode("mn", [text], ["special-fraction"])
|
|
10653
10614
|
}
|
|
10654
10615
|
});
|
|
10655
10616
|
|
|
@@ -10762,7 +10723,7 @@ defineFunction({
|
|
|
10762
10723
|
};
|
|
10763
10724
|
},
|
|
10764
10725
|
mathmlBuilder: (group, style) => {
|
|
10765
|
-
const node = new
|
|
10726
|
+
const node = new MathNode("mpadded", [buildGroup$1(group.body, style)]);
|
|
10766
10727
|
|
|
10767
10728
|
if (group.smashHeight) {
|
|
10768
10729
|
node.setAttribute("height", "0px");
|
|
@@ -10815,11 +10776,11 @@ defineFunction({
|
|
|
10815
10776
|
mathmlBuilder(group, style) {
|
|
10816
10777
|
const { body, index } = group;
|
|
10817
10778
|
return index
|
|
10818
|
-
? new
|
|
10779
|
+
? new MathNode("mroot", [
|
|
10819
10780
|
buildGroup$1(body, style),
|
|
10820
10781
|
buildGroup$1(index, style.incrementLevel())
|
|
10821
10782
|
])
|
|
10822
|
-
: new
|
|
10783
|
+
: new MathNode("msqrt", [buildGroup$1(body, style)]);
|
|
10823
10784
|
}
|
|
10824
10785
|
});
|
|
10825
10786
|
|
|
@@ -11018,26 +10979,26 @@ defineFunctionBuilders({
|
|
|
11018
10979
|
}
|
|
11019
10980
|
}
|
|
11020
10981
|
|
|
11021
|
-
let node = new
|
|
10982
|
+
let node = new MathNode(nodeType, children);
|
|
11022
10983
|
if (appendApplyFunction) {
|
|
11023
10984
|
// Append an <mo>⁡</mo>.
|
|
11024
10985
|
// ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
|
|
11025
|
-
const operator = new
|
|
10986
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
11026
10987
|
if (needsLeadingSpace) {
|
|
11027
|
-
const space = new
|
|
10988
|
+
const space = new MathNode("mspace");
|
|
11028
10989
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
11029
|
-
node =
|
|
10990
|
+
node = newDocumentFragment([space, node, operator]);
|
|
11030
10991
|
} else {
|
|
11031
|
-
node =
|
|
10992
|
+
node = newDocumentFragment([node, operator]);
|
|
11032
10993
|
}
|
|
11033
10994
|
if (appendSpace) {
|
|
11034
|
-
const space = new
|
|
10995
|
+
const space = new MathNode("mspace");
|
|
11035
10996
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
11036
10997
|
node.children.push(space);
|
|
11037
10998
|
}
|
|
11038
10999
|
} else if (symbolRegEx.test(nodeType)) {
|
|
11039
11000
|
// Wrap in a <mrow>. Otherwise Firefox stretchy parens will not stretch to include limits.
|
|
11040
|
-
node = new
|
|
11001
|
+
node = new MathNode("mrow", [node]);
|
|
11041
11002
|
}
|
|
11042
11003
|
|
|
11043
11004
|
return node
|
|
@@ -11062,7 +11023,7 @@ const isArrow = str => {
|
|
|
11062
11023
|
defineFunctionBuilders({
|
|
11063
11024
|
type: "atom",
|
|
11064
11025
|
mathmlBuilder(group, style) {
|
|
11065
|
-
const node = new
|
|
11026
|
+
const node = new MathNode("mo", [makeText(group.text, group.mode)]);
|
|
11066
11027
|
if (group.family === "punct") {
|
|
11067
11028
|
node.setAttribute("separator", "true");
|
|
11068
11029
|
} else if (group.family === "open" || group.family === "close") {
|
|
@@ -11092,10 +11053,10 @@ defineFunctionBuilders({
|
|
|
11092
11053
|
} else if (group.needsSpacing) {
|
|
11093
11054
|
// Fix a MathML bug that occurs when a <mo> is between two <mtext> elements.
|
|
11094
11055
|
if (group.family === "bin") {
|
|
11095
|
-
return new
|
|
11056
|
+
return new MathNode("mrow", [padding(0.222), node, padding(0.222)])
|
|
11096
11057
|
} else {
|
|
11097
11058
|
// REL spacing
|
|
11098
|
-
return new
|
|
11059
|
+
return new MathNode("mrow", [padding(0.2778), node, padding(0.2778)])
|
|
11099
11060
|
}
|
|
11100
11061
|
}
|
|
11101
11062
|
return node;
|
|
@@ -11436,8 +11397,8 @@ const primes = new Set(["\\prime", "\\dprime", "\\trprime", "\\qprime",
|
|
|
11436
11397
|
"\\backprime", "\\backdprime", "\\backtrprime"]);
|
|
11437
11398
|
|
|
11438
11399
|
const italicNumber = (text, variant, tag) => {
|
|
11439
|
-
const mn = new
|
|
11440
|
-
const wrapper = new
|
|
11400
|
+
const mn = new MathNode(tag, [text]);
|
|
11401
|
+
const wrapper = new MathNode("mstyle", [mn]);
|
|
11441
11402
|
wrapper.style["font-style"] = "italic";
|
|
11442
11403
|
wrapper.style["font-family"] = "Cambria, 'Times New Roman', serif";
|
|
11443
11404
|
if (variant === "bold-italic") { wrapper.style["font-weight"] = "bold"; }
|
|
@@ -11454,17 +11415,17 @@ defineFunctionBuilders({
|
|
|
11454
11415
|
const variant = getVariant(group, style) || defaultVariant;
|
|
11455
11416
|
if (variant === "script") {
|
|
11456
11417
|
text.text = variantChar(text.text, variant);
|
|
11457
|
-
return new
|
|
11418
|
+
return new MathNode("mi", [text], [style.font])
|
|
11458
11419
|
} else if (variant !== "italic") {
|
|
11459
11420
|
text.text = variantChar(text.text, variant);
|
|
11460
11421
|
}
|
|
11461
|
-
let node = new
|
|
11422
|
+
let node = new MathNode("mi", [text]);
|
|
11462
11423
|
// TODO: Handle U+1D49C - U+1D4CF per https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
11463
11424
|
if (variant === "normal") {
|
|
11464
11425
|
node.setAttribute("mathvariant", "normal");
|
|
11465
11426
|
if (text.text.length === 1) {
|
|
11466
11427
|
// A Firefox bug will apply spacing here, but there should be none. Fix it.
|
|
11467
|
-
node = new
|
|
11428
|
+
node = new MathNode("mpadded", [node]);
|
|
11468
11429
|
node.setAttribute("lspace", "0");
|
|
11469
11430
|
}
|
|
11470
11431
|
}
|
|
@@ -11495,15 +11456,15 @@ defineFunctionBuilders({
|
|
|
11495
11456
|
if (variant !== "normal") {
|
|
11496
11457
|
text.text = text.text.split("").map(c => variantChar(c, variant)).join("");
|
|
11497
11458
|
}
|
|
11498
|
-
node = new
|
|
11459
|
+
node = new MathNode(tag, [text]);
|
|
11499
11460
|
}
|
|
11500
11461
|
} else if (group.mode === "text") {
|
|
11501
11462
|
if (variant !== "normal") {
|
|
11502
11463
|
text.text = variantChar(text.text, variant);
|
|
11503
11464
|
}
|
|
11504
|
-
node = new
|
|
11465
|
+
node = new MathNode("mtext", [text]);
|
|
11505
11466
|
} else if (primes.has(group.text)) {
|
|
11506
|
-
node = new
|
|
11467
|
+
node = new MathNode("mo", [text]);
|
|
11507
11468
|
// TODO: If/when Chromium uses ssty variant for prime, remove the next line.
|
|
11508
11469
|
node.classes.push("tml-prime");
|
|
11509
11470
|
} else {
|
|
@@ -11511,7 +11472,7 @@ defineFunctionBuilders({
|
|
|
11511
11472
|
if (variant !== "italic") {
|
|
11512
11473
|
text.text = variantChar(text.text, variant);
|
|
11513
11474
|
}
|
|
11514
|
-
node = new
|
|
11475
|
+
node = new MathNode("mi", [text]);
|
|
11515
11476
|
if (text.text === origText && latinRegEx.test(origText)) {
|
|
11516
11477
|
node.setAttribute("mathvariant", "italic");
|
|
11517
11478
|
}
|
|
@@ -11554,11 +11515,11 @@ defineFunctionBuilders({
|
|
|
11554
11515
|
// Firefox does not render a space in a <mtext> </mtext>. So write a no-break space.
|
|
11555
11516
|
// TODO: If Firefox fixes that bug, uncomment the next line and write ch into the node.
|
|
11556
11517
|
//const ch = (regularSpace[group.text].className === "nobreak") ? "\u00a0" : " "
|
|
11557
|
-
node = new
|
|
11518
|
+
node = new MathNode("mtext", [new TextNode("\u00a0")]);
|
|
11558
11519
|
} else if (Object.prototype.hasOwnProperty.call(cssSpace, group.text)) {
|
|
11559
11520
|
// MathML 3.0 calls for nobreak to occur in an <mo>, not an <mtext>
|
|
11560
11521
|
// Ref: https://www.w3.org/Math/draft-spec/mathml.html#chapter3_presm.lbattrs
|
|
11561
|
-
node = new
|
|
11522
|
+
node = new MathNode("mo");
|
|
11562
11523
|
if (group.text === "\\nobreak") {
|
|
11563
11524
|
node.setAttribute("linebreak", "nobreak");
|
|
11564
11525
|
}
|
|
@@ -11673,10 +11634,10 @@ defineFunction({
|
|
|
11673
11634
|
},
|
|
11674
11635
|
mathmlBuilder(group, style) {
|
|
11675
11636
|
// Use a math table to create vertically centered content.
|
|
11676
|
-
const mtd = new
|
|
11637
|
+
const mtd = new MathNode("mtd", [buildGroup$1(group.body, style)]);
|
|
11677
11638
|
mtd.style.padding = "0";
|
|
11678
|
-
const mtr = new
|
|
11679
|
-
return new
|
|
11639
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
11640
|
+
return new MathNode("mtable", [mtr])
|
|
11680
11641
|
}
|
|
11681
11642
|
});
|
|
11682
11643
|
|
|
@@ -11695,8 +11656,8 @@ defineFunction({
|
|
|
11695
11656
|
throw new ParseError("\\verb ended by end of line instead of matching delimiter");
|
|
11696
11657
|
},
|
|
11697
11658
|
mathmlBuilder(group, style) {
|
|
11698
|
-
const text = new
|
|
11699
|
-
const node = new
|
|
11659
|
+
const text = new TextNode(makeVerb(group));
|
|
11660
|
+
const node = new MathNode("mtext", [text]);
|
|
11700
11661
|
node.setAttribute("mathvariant", "monospace");
|
|
11701
11662
|
return node;
|
|
11702
11663
|
}
|
|
@@ -14028,7 +13989,7 @@ class Style {
|
|
|
14028
13989
|
* https://mit-license.org/
|
|
14029
13990
|
*/
|
|
14030
13991
|
|
|
14031
|
-
const version = "0.
|
|
13992
|
+
const version = "0.12.01";
|
|
14032
13993
|
|
|
14033
13994
|
function postProcess(block) {
|
|
14034
13995
|
const labelMap = {};
|