temml 0.11.11 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Temml-Asana.css +28 -0
- package/dist/Temml-Latin-Modern.css +29 -1
- package/dist/Temml-Libertinus.css +28 -0
- package/dist/Temml-Local.css +28 -0
- package/dist/Temml-NotoSans.css +28 -0
- package/dist/Temml-STIX2.css +28 -0
- package/dist/temml.cjs +305 -253
- package/dist/temml.d.ts +2 -2
- package/dist/temml.js +305 -253
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +305 -253
- 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/canceltoArrow.svg +15 -0
- package/src/domTree.js +1 -1
- package/src/environments/array.js +7 -7
- package/src/environments/cd.js +1 -1
- package/src/functions/accent.js +3 -4
- package/src/functions/accentunder.js +2 -2
- package/src/functions/arrow.js +2 -2
- package/src/functions/cancelto.js +56 -16
- 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 +8 -10
- 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 → horizBracket.js} +6 -6
- 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/op.js +2 -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 +6 -6
- 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/functions.js +2 -2
- package/src/linebreaking.js +1 -1
- package/src/mathMLTree.js +1 -7
- package/src/postProcess.js +1 -1
- package/src/stretchy.js +5 -8
- package/src/units.js +1 -1
- package/src/utils.js +8 -15
package/dist/temml.mjs
CHANGED
|
@@ -179,15 +179,8 @@ const round = function(n) {
|
|
|
179
179
|
return +n.toFixed(4);
|
|
180
180
|
};
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
escape,
|
|
185
|
-
hyphenate,
|
|
186
|
-
getBaseElem,
|
|
187
|
-
isCharacterBox,
|
|
188
|
-
protocolFromUrl,
|
|
189
|
-
round
|
|
190
|
-
};
|
|
182
|
+
// Identify short letters. Used for accents and \cancelto.
|
|
183
|
+
const smalls = "acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳";
|
|
191
184
|
|
|
192
185
|
/**
|
|
193
186
|
* This is a module for storing settings passed into Temml. It correctly handles
|
|
@@ -202,24 +195,24 @@ class Settings {
|
|
|
202
195
|
constructor(options) {
|
|
203
196
|
// allow null options
|
|
204
197
|
options = options || {};
|
|
205
|
-
this.displayMode =
|
|
206
|
-
this.annotate =
|
|
207
|
-
this.leqno =
|
|
208
|
-
this.throwOnError =
|
|
209
|
-
this.errorColor =
|
|
198
|
+
this.displayMode = deflt(options.displayMode, false); // boolean
|
|
199
|
+
this.annotate = deflt(options.annotate, false); // boolean
|
|
200
|
+
this.leqno = deflt(options.leqno, false); // boolean
|
|
201
|
+
this.throwOnError = deflt(options.throwOnError, false); // boolean
|
|
202
|
+
this.errorColor = deflt(options.errorColor, "#b22222"); // string
|
|
210
203
|
this.macros = options.macros || {};
|
|
211
|
-
this.wrap =
|
|
212
|
-
this.xml =
|
|
213
|
-
this.colorIsTextColor =
|
|
214
|
-
this.strict =
|
|
215
|
-
this.trust =
|
|
204
|
+
this.wrap = deflt(options.wrap, "none"); // "none" | "tex" | "="
|
|
205
|
+
this.xml = deflt(options.xml, false); // boolean
|
|
206
|
+
this.colorIsTextColor = deflt(options.colorIsTextColor, false); // boolean
|
|
207
|
+
this.strict = deflt(options.strict, false); // boolean
|
|
208
|
+
this.trust = deflt(options.trust, false); // trust context. See html.js.
|
|
216
209
|
this.maxSize = (options.maxSize === undefined
|
|
217
210
|
? [Infinity, Infinity]
|
|
218
211
|
: Array.isArray(options.maxSize)
|
|
219
212
|
? options.maxSize
|
|
220
213
|
: [Infinity, Infinity]
|
|
221
214
|
);
|
|
222
|
-
this.maxExpand = Math.max(0,
|
|
215
|
+
this.maxExpand = Math.max(0, deflt(options.maxExpand, 1000)); // number
|
|
223
216
|
}
|
|
224
217
|
|
|
225
218
|
/**
|
|
@@ -232,7 +225,7 @@ class Settings {
|
|
|
232
225
|
*/
|
|
233
226
|
isTrusted(context) {
|
|
234
227
|
if (context.url && !context.protocol) {
|
|
235
|
-
const protocol =
|
|
228
|
+
const protocol = protocolFromUrl(context.url);
|
|
236
229
|
if (protocol == null) {
|
|
237
230
|
return false
|
|
238
231
|
}
|
|
@@ -428,7 +421,7 @@ const toMarkup = function(tagName) {
|
|
|
428
421
|
|
|
429
422
|
// Add the class
|
|
430
423
|
if (this.classes.length) {
|
|
431
|
-
markup += ` class="${
|
|
424
|
+
markup += ` class="${escape(createClass(this.classes))}"`;
|
|
432
425
|
}
|
|
433
426
|
|
|
434
427
|
let styles = "";
|
|
@@ -436,7 +429,7 @@ const toMarkup = function(tagName) {
|
|
|
436
429
|
// Add the styles, after hyphenation
|
|
437
430
|
for (const style in this.style) {
|
|
438
431
|
if (Object.prototype.hasOwnProperty.call(this.style, style )) {
|
|
439
|
-
styles += `${
|
|
432
|
+
styles += `${hyphenate(style)}:${this.style[style]};`;
|
|
440
433
|
}
|
|
441
434
|
}
|
|
442
435
|
|
|
@@ -447,7 +440,7 @@ const toMarkup = function(tagName) {
|
|
|
447
440
|
// Add the attributes
|
|
448
441
|
for (const attr in this.attributes) {
|
|
449
442
|
if (Object.prototype.hasOwnProperty.call(this.attributes, attr )) {
|
|
450
|
-
markup += ` ${attr}="${
|
|
443
|
+
markup += ` ${attr}="${escape(this.attributes[attr])}"`;
|
|
451
444
|
}
|
|
452
445
|
}
|
|
453
446
|
|
|
@@ -495,7 +488,7 @@ let TextNode$1 = class TextNode {
|
|
|
495
488
|
return document.createTextNode(this.text);
|
|
496
489
|
}
|
|
497
490
|
toMarkup() {
|
|
498
|
-
return
|
|
491
|
+
return escape(this.text);
|
|
499
492
|
}
|
|
500
493
|
};
|
|
501
494
|
|
|
@@ -520,9 +513,9 @@ class AnchorNode {
|
|
|
520
513
|
}
|
|
521
514
|
|
|
522
515
|
toMarkup() {
|
|
523
|
-
let markup = `<a href='${
|
|
516
|
+
let markup = `<a href='${escape(this.href)}'`;
|
|
524
517
|
if (this.classes.length > 0) {
|
|
525
|
-
markup += ` class="${
|
|
518
|
+
markup += ` class="${escape(createClass(this.classes))}"`;
|
|
526
519
|
}
|
|
527
520
|
markup += ">";
|
|
528
521
|
for (let i = 0; i < this.children.length; i++) {
|
|
@@ -571,11 +564,11 @@ class Img {
|
|
|
571
564
|
let styles = "";
|
|
572
565
|
for (const style in this.style) {
|
|
573
566
|
if (Object.prototype.hasOwnProperty.call(this.style, style )) {
|
|
574
|
-
styles += `${
|
|
567
|
+
styles += `${hyphenate(style)}:${this.style[style]};`;
|
|
575
568
|
}
|
|
576
569
|
}
|
|
577
570
|
if (styles) {
|
|
578
|
-
markup += ` style="${
|
|
571
|
+
markup += ` style="${escape(styles)}"`;
|
|
579
572
|
}
|
|
580
573
|
|
|
581
574
|
markup += ">";
|
|
@@ -669,13 +662,13 @@ class MathNode {
|
|
|
669
662
|
for (const attr in this.attributes) {
|
|
670
663
|
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
671
664
|
markup += " " + attr + '="';
|
|
672
|
-
markup +=
|
|
665
|
+
markup += escape(this.attributes[attr]);
|
|
673
666
|
markup += '"';
|
|
674
667
|
}
|
|
675
668
|
}
|
|
676
669
|
|
|
677
670
|
if (this.classes.length > 0) {
|
|
678
|
-
markup += ` class="${
|
|
671
|
+
markup += ` class="${escape(createClass(this.classes))}"`;
|
|
679
672
|
}
|
|
680
673
|
|
|
681
674
|
let styles = "";
|
|
@@ -683,7 +676,7 @@ class MathNode {
|
|
|
683
676
|
// Add the styles, after hyphenation
|
|
684
677
|
for (const style in this.style) {
|
|
685
678
|
if (Object.prototype.hasOwnProperty.call(this.style, style )) {
|
|
686
|
-
styles += `${
|
|
679
|
+
styles += `${hyphenate(style)}:${this.style[style]};`;
|
|
687
680
|
}
|
|
688
681
|
}
|
|
689
682
|
|
|
@@ -730,7 +723,7 @@ class TextNode {
|
|
|
730
723
|
* (representing the text itself).
|
|
731
724
|
*/
|
|
732
725
|
toMarkup() {
|
|
733
|
-
return
|
|
726
|
+
return escape(this.toText());
|
|
734
727
|
}
|
|
735
728
|
|
|
736
729
|
/**
|
|
@@ -755,12 +748,6 @@ const wrapWithMstyle = expression => {
|
|
|
755
748
|
return node
|
|
756
749
|
};
|
|
757
750
|
|
|
758
|
-
var mathMLTree = {
|
|
759
|
-
MathNode,
|
|
760
|
-
TextNode,
|
|
761
|
-
newDocumentFragment
|
|
762
|
-
};
|
|
763
|
-
|
|
764
751
|
/**
|
|
765
752
|
* This file provides support for building horizontal stretchy elements.
|
|
766
753
|
*/
|
|
@@ -810,6 +797,8 @@ const stretchyCodePoint = {
|
|
|
810
797
|
xrightarrow: "\u2192",
|
|
811
798
|
underbrace: "\u23df",
|
|
812
799
|
overbrace: "\u23de",
|
|
800
|
+
overbracket: "\u23b4",
|
|
801
|
+
underbracket: "\u23b5",
|
|
813
802
|
overgroup: "\u23e0",
|
|
814
803
|
overparen: "⏜",
|
|
815
804
|
undergroup: "\u23e1",
|
|
@@ -852,8 +841,8 @@ const stretchyCodePoint = {
|
|
|
852
841
|
};
|
|
853
842
|
|
|
854
843
|
const mathMLnode = function(label) {
|
|
855
|
-
const child = new
|
|
856
|
-
const node = new
|
|
844
|
+
const child = new TextNode(stretchyCodePoint[label.slice(1)]);
|
|
845
|
+
const node = new MathNode("mo", [child]);
|
|
857
846
|
node.setAttribute("stretchy", "true");
|
|
858
847
|
return node
|
|
859
848
|
};
|
|
@@ -876,11 +865,6 @@ const accentNode = (group) => {
|
|
|
876
865
|
return mo
|
|
877
866
|
};
|
|
878
867
|
|
|
879
|
-
var stretchy = {
|
|
880
|
-
mathMLnode,
|
|
881
|
-
accentNode
|
|
882
|
-
};
|
|
883
|
-
|
|
884
868
|
/**
|
|
885
869
|
* This file holds a list of all no-argument functions and single-character
|
|
886
870
|
* symbols (like 'a' or ';').
|
|
@@ -2034,13 +2018,13 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
|
2034
2018
|
node.attributes.linebreak === "newline") {
|
|
2035
2019
|
// A hard line break. Create a <mtr> for the current block.
|
|
2036
2020
|
if (block.length > 0) {
|
|
2037
|
-
mrows.push(new
|
|
2021
|
+
mrows.push(new MathNode("mrow", block));
|
|
2038
2022
|
}
|
|
2039
2023
|
mrows.push(node);
|
|
2040
2024
|
block = [];
|
|
2041
|
-
const mtd = new
|
|
2025
|
+
const mtd = new MathNode("mtd", mrows);
|
|
2042
2026
|
mtd.style.textAlign = "left";
|
|
2043
|
-
mtrs.push(new
|
|
2027
|
+
mtrs.push(new MathNode("mtr", [mtd]));
|
|
2044
2028
|
mrows = [];
|
|
2045
2029
|
i += 1;
|
|
2046
2030
|
continue
|
|
@@ -2058,7 +2042,7 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
|
2058
2042
|
if (numTopLevelEquals > 1) {
|
|
2059
2043
|
block.pop();
|
|
2060
2044
|
// Start a new block. (Insert a soft linebreak.)
|
|
2061
|
-
const element = new
|
|
2045
|
+
const element = new MathNode("mrow", block);
|
|
2062
2046
|
mrows.push(element);
|
|
2063
2047
|
block = [node];
|
|
2064
2048
|
}
|
|
@@ -2099,7 +2083,7 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
|
2099
2083
|
}
|
|
2100
2084
|
if (glueIsFreeOfNobreak) {
|
|
2101
2085
|
// Start a new block. (Insert a soft linebreak.)
|
|
2102
|
-
const element = new
|
|
2086
|
+
const element = new MathNode("mrow", block);
|
|
2103
2087
|
mrows.push(element);
|
|
2104
2088
|
block = [];
|
|
2105
2089
|
}
|
|
@@ -2108,22 +2092,22 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
|
2108
2092
|
i += 1;
|
|
2109
2093
|
}
|
|
2110
2094
|
if (block.length > 0) {
|
|
2111
|
-
const element = new
|
|
2095
|
+
const element = new MathNode("mrow", block);
|
|
2112
2096
|
mrows.push(element);
|
|
2113
2097
|
}
|
|
2114
2098
|
if (mtrs.length > 0) {
|
|
2115
|
-
const mtd = new
|
|
2099
|
+
const mtd = new MathNode("mtd", mrows);
|
|
2116
2100
|
mtd.style.textAlign = "left";
|
|
2117
|
-
const mtr = new
|
|
2101
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
2118
2102
|
mtrs.push(mtr);
|
|
2119
|
-
const mtable = new
|
|
2103
|
+
const mtable = new MathNode("mtable", mtrs);
|
|
2120
2104
|
if (!isDisplayMode) {
|
|
2121
2105
|
mtable.setAttribute("columnalign", "left");
|
|
2122
2106
|
mtable.setAttribute("rowspacing", "0em");
|
|
2123
2107
|
}
|
|
2124
2108
|
return mtable
|
|
2125
2109
|
}
|
|
2126
|
-
return
|
|
2110
|
+
return newDocumentFragment(mrows);
|
|
2127
2111
|
}
|
|
2128
2112
|
|
|
2129
2113
|
/**
|
|
@@ -2152,15 +2136,15 @@ const makeText = function(text, mode, style) {
|
|
|
2152
2136
|
text = symbols[mode][text].replace;
|
|
2153
2137
|
}
|
|
2154
2138
|
|
|
2155
|
-
return new
|
|
2139
|
+
return new TextNode(text);
|
|
2156
2140
|
};
|
|
2157
2141
|
|
|
2158
2142
|
const copyChar = (newRow, child) => {
|
|
2159
2143
|
if (newRow.children.length === 0 ||
|
|
2160
2144
|
newRow.children[newRow.children.length - 1].type !== "mtext") {
|
|
2161
|
-
const mtext = new
|
|
2145
|
+
const mtext = new MathNode(
|
|
2162
2146
|
"mtext",
|
|
2163
|
-
[new
|
|
2147
|
+
[new TextNode(child.children[0].text)]
|
|
2164
2148
|
);
|
|
2165
2149
|
newRow.children.push(mtext);
|
|
2166
2150
|
} else {
|
|
@@ -2172,7 +2156,7 @@ const consolidateText = mrow => {
|
|
|
2172
2156
|
// If possible, consolidate adjacent <mtext> elements into a single element.
|
|
2173
2157
|
if (mrow.type !== "mrow" && mrow.type !== "mstyle") { return mrow }
|
|
2174
2158
|
if (mrow.children.length === 0) { return mrow } // empty group, e.g., \text{}
|
|
2175
|
-
const newRow = new
|
|
2159
|
+
const newRow = new MathNode("mrow");
|
|
2176
2160
|
for (let i = 0; i < mrow.children.length; i++) {
|
|
2177
2161
|
const child = mrow.children[i];
|
|
2178
2162
|
if (child.type === "mtext" && Object.keys(child.attributes).length === 0) {
|
|
@@ -2242,7 +2226,7 @@ const makeRow = function(body, semisimple = false) {
|
|
|
2242
2226
|
body[end].attributes.rspace = "0em";
|
|
2243
2227
|
}
|
|
2244
2228
|
}
|
|
2245
|
-
return new
|
|
2229
|
+
return new MathNode("mrow", body);
|
|
2246
2230
|
};
|
|
2247
2231
|
|
|
2248
2232
|
/**
|
|
@@ -2367,7 +2351,7 @@ const buildExpressionRow = function(expression, style, semisimple = false) {
|
|
|
2367
2351
|
*/
|
|
2368
2352
|
const buildGroup$1 = function(group, style) {
|
|
2369
2353
|
if (!group) {
|
|
2370
|
-
return new
|
|
2354
|
+
return new MathNode("mrow");
|
|
2371
2355
|
}
|
|
2372
2356
|
|
|
2373
2357
|
if (_mathmlGroupBuilders[group.type]) {
|
|
@@ -2380,7 +2364,7 @@ const buildGroup$1 = function(group, style) {
|
|
|
2380
2364
|
};
|
|
2381
2365
|
|
|
2382
2366
|
const glue$1 = _ => {
|
|
2383
|
-
return new
|
|
2367
|
+
return new MathNode("mtd", [], [], { padding: "0", width: "50%" })
|
|
2384
2368
|
};
|
|
2385
2369
|
|
|
2386
2370
|
const labelContainers = ["mrow", "mtd", "mtable", "mtr"];
|
|
@@ -2407,12 +2391,12 @@ const taggedExpression = (expression, tag, style, leqno) => {
|
|
|
2407
2391
|
tag.classes.push("tml-tag"); // to be available for \ref
|
|
2408
2392
|
|
|
2409
2393
|
const label = getLabel(expression); // from a \label{} function.
|
|
2410
|
-
expression = new
|
|
2394
|
+
expression = new MathNode("mtd", [expression]);
|
|
2411
2395
|
const rowArray = [glue$1(), expression, glue$1()];
|
|
2412
2396
|
rowArray[leqno ? 0 : 2].children.push(tag);
|
|
2413
|
-
const mtr = new
|
|
2397
|
+
const mtr = new MathNode("mtr", rowArray, ["tml-tageqn"]);
|
|
2414
2398
|
if (label) { mtr.setAttribute("id", label); }
|
|
2415
|
-
const table = new
|
|
2399
|
+
const table = new MathNode("mtable", [mtr]);
|
|
2416
2400
|
table.style.width = "100%";
|
|
2417
2401
|
table.setAttribute("displaystyle", "true");
|
|
2418
2402
|
return table
|
|
@@ -2449,13 +2433,13 @@ function buildMathML(tree, texExpression, style, settings) {
|
|
|
2449
2433
|
|
|
2450
2434
|
if (settings.annotate) {
|
|
2451
2435
|
// Build a TeX annotation of the source
|
|
2452
|
-
const annotation = new
|
|
2453
|
-
"annotation", [new
|
|
2436
|
+
const annotation = new MathNode(
|
|
2437
|
+
"annotation", [new TextNode(texExpression)]);
|
|
2454
2438
|
annotation.setAttribute("encoding", "application/x-tex");
|
|
2455
|
-
wrapper = new
|
|
2439
|
+
wrapper = new MathNode("semantics", [wrapper, annotation]);
|
|
2456
2440
|
}
|
|
2457
2441
|
|
|
2458
|
-
const math = new
|
|
2442
|
+
const math = new MathNode("math", [wrapper]);
|
|
2459
2443
|
|
|
2460
2444
|
if (settings.xml) {
|
|
2461
2445
|
math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
|
|
@@ -2470,23 +2454,20 @@ function buildMathML(tree, texExpression, style, settings) {
|
|
|
2470
2454
|
return math;
|
|
2471
2455
|
}
|
|
2472
2456
|
|
|
2473
|
-
// Identify letters to which we'll attach a combining accent character
|
|
2474
|
-
const smalls = "acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳";
|
|
2475
|
-
|
|
2476
2457
|
// From the KaTeX font metrics, identify letters whose accents need a italic correction.
|
|
2477
2458
|
const smallNudge = "DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ";
|
|
2478
2459
|
const mediumNudge = "BCEGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ";
|
|
2479
2460
|
const largeNudge = "AFJdfΔΛ";
|
|
2480
2461
|
|
|
2481
2462
|
const mathmlBuilder$a = (group, style) => {
|
|
2482
|
-
const accentNode = group.isStretchy
|
|
2483
|
-
?
|
|
2484
|
-
: new
|
|
2463
|
+
const accentNode$1 = group.isStretchy
|
|
2464
|
+
? accentNode(group)
|
|
2465
|
+
: new MathNode("mo", [makeText(group.label, group.mode)]);
|
|
2485
2466
|
if (!group.isStretchy) {
|
|
2486
|
-
accentNode.setAttribute("stretchy", "false"); // Keep Firefox from stretching \check
|
|
2467
|
+
accentNode$1.setAttribute("stretchy", "false"); // Keep Firefox from stretching \check
|
|
2487
2468
|
}
|
|
2488
2469
|
if (group.label !== "\\vec") {
|
|
2489
|
-
accentNode.style.mathDepth = "0"; // not scriptstyle
|
|
2470
|
+
accentNode$1.style.mathDepth = "0"; // not scriptstyle
|
|
2490
2471
|
// Don't use attribute accent="true" because MathML Core eliminates a needed space.
|
|
2491
2472
|
}
|
|
2492
2473
|
const tag = group.label === "\\c" ? "munder" : "mover";
|
|
@@ -2497,28 +2478,28 @@ const mathmlBuilder$a = (group, style) => {
|
|
|
2497
2478
|
const isVec = group.label === "\\vec";
|
|
2498
2479
|
const vecPostfix = isVec === "\\vec" ? "-vec" : "";
|
|
2499
2480
|
if (isVec) {
|
|
2500
|
-
accentNode.classes.push("tml-vec"); // Firefox sizing of \vec arrow
|
|
2481
|
+
accentNode$1.classes.push("tml-vec"); // Firefox sizing of \vec arrow
|
|
2501
2482
|
}
|
|
2502
2483
|
const wbkPostfix = isVec ? "-vec" : needsWbkVertShift ? "-acc" : "";
|
|
2503
2484
|
if (smallNudge.indexOf(text) > -1) {
|
|
2504
|
-
accentNode.classes.push(`chr-sml${vecPostfix}`);
|
|
2505
|
-
accentNode.classes.push(`wbk-sml${wbkPostfix}`);
|
|
2485
|
+
accentNode$1.classes.push(`chr-sml${vecPostfix}`);
|
|
2486
|
+
accentNode$1.classes.push(`wbk-sml${wbkPostfix}`);
|
|
2506
2487
|
} else if (mediumNudge.indexOf(text) > -1) {
|
|
2507
|
-
accentNode.classes.push(`chr-med${vecPostfix}`);
|
|
2508
|
-
accentNode.classes.push(`wbk-med${wbkPostfix}`);
|
|
2488
|
+
accentNode$1.classes.push(`chr-med${vecPostfix}`);
|
|
2489
|
+
accentNode$1.classes.push(`wbk-med${wbkPostfix}`);
|
|
2509
2490
|
} else if (largeNudge.indexOf(text) > -1) {
|
|
2510
|
-
accentNode.classes.push(`chr-lrg${vecPostfix}`);
|
|
2511
|
-
accentNode.classes.push(`wbk-lrg${wbkPostfix}`);
|
|
2491
|
+
accentNode$1.classes.push(`chr-lrg${vecPostfix}`);
|
|
2492
|
+
accentNode$1.classes.push(`wbk-lrg${wbkPostfix}`);
|
|
2512
2493
|
} else if (isVec) {
|
|
2513
|
-
accentNode.classes.push(`wbk-vec`);
|
|
2494
|
+
accentNode$1.classes.push(`wbk-vec`);
|
|
2514
2495
|
} else if (needsWbkVertShift) {
|
|
2515
|
-
accentNode.classes.push(`wbk-acc`);
|
|
2496
|
+
accentNode$1.classes.push(`wbk-acc`);
|
|
2516
2497
|
}
|
|
2517
2498
|
} else if (needsWbkVertShift) {
|
|
2518
2499
|
// text-mode accents
|
|
2519
|
-
accentNode.classes.push("wbk-acc");
|
|
2500
|
+
accentNode$1.classes.push("wbk-acc");
|
|
2520
2501
|
}
|
|
2521
|
-
const node = new
|
|
2502
|
+
const node = new MathNode(tag, [buildGroup$1(group.base, style), accentNode$1]);
|
|
2522
2503
|
return node;
|
|
2523
2504
|
};
|
|
2524
2505
|
|
|
@@ -2685,11 +2666,11 @@ defineFunction({
|
|
|
2685
2666
|
};
|
|
2686
2667
|
},
|
|
2687
2668
|
mathmlBuilder: (group, style) => {
|
|
2688
|
-
const accentNode =
|
|
2689
|
-
accentNode.style["math-depth"] = 0;
|
|
2690
|
-
const node = new
|
|
2669
|
+
const accentNode$1 = accentNode(group);
|
|
2670
|
+
accentNode$1.style["math-depth"] = 0;
|
|
2671
|
+
const node = new MathNode("munder", [
|
|
2691
2672
|
buildGroup$1(group.base, style),
|
|
2692
|
-
accentNode
|
|
2673
|
+
accentNode$1
|
|
2693
2674
|
]);
|
|
2694
2675
|
return node;
|
|
2695
2676
|
}
|
|
@@ -2778,7 +2759,7 @@ const calculateSize = function(sizeValue, style) {
|
|
|
2778
2759
|
// In TeX, em and ex do not change size in \scriptstyle.
|
|
2779
2760
|
if (unit === "ex") { number *= 0.431; }
|
|
2780
2761
|
number = Math.min(number / emScale(style.level), style.maxSize[0]);
|
|
2781
|
-
return { number:
|
|
2762
|
+
return { number: round(number), unit: "em" };
|
|
2782
2763
|
}
|
|
2783
2764
|
case "bp": {
|
|
2784
2765
|
if (number > style.maxSize[1]) { number = style.maxSize[1]; }
|
|
@@ -2792,11 +2773,11 @@ const calculateSize = function(sizeValue, style) {
|
|
|
2792
2773
|
case "nc":
|
|
2793
2774
|
case "sp": {
|
|
2794
2775
|
number = Math.min(number * ptPerUnit[unit], style.maxSize[1]);
|
|
2795
|
-
return { number:
|
|
2776
|
+
return { number: round(number), unit: "pt" }
|
|
2796
2777
|
}
|
|
2797
2778
|
case "mu": {
|
|
2798
2779
|
number = Math.min(number / 18, style.maxSize[0]);
|
|
2799
|
-
return { number:
|
|
2780
|
+
return { number: round(number), unit: "em" }
|
|
2800
2781
|
}
|
|
2801
2782
|
default:
|
|
2802
2783
|
throw new ParseError("Invalid unit: '" + unit + "'")
|
|
@@ -2806,7 +2787,7 @@ const calculateSize = function(sizeValue, style) {
|
|
|
2806
2787
|
// Helper functions
|
|
2807
2788
|
|
|
2808
2789
|
const padding = width => {
|
|
2809
|
-
const node = new
|
|
2790
|
+
const node = new MathNode("mspace");
|
|
2810
2791
|
node.setAttribute("width", width + "em");
|
|
2811
2792
|
return node
|
|
2812
2793
|
};
|
|
@@ -2818,18 +2799,18 @@ const paddedNode = (group, lspace = 0.3, rspace = 0, mustSmash = false) => {
|
|
|
2818
2799
|
if (rspace > 0) { row.push(padding(rspace)); }
|
|
2819
2800
|
if (mustSmash) {
|
|
2820
2801
|
// Used for the bottom arrow in a {CD} environment
|
|
2821
|
-
const mpadded = new
|
|
2802
|
+
const mpadded = new MathNode("mpadded", row);
|
|
2822
2803
|
mpadded.setAttribute("height", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
2823
2804
|
return mpadded
|
|
2824
2805
|
} else {
|
|
2825
|
-
return new
|
|
2806
|
+
return new MathNode("mrow", row)
|
|
2826
2807
|
}
|
|
2827
2808
|
};
|
|
2828
2809
|
|
|
2829
2810
|
const labelSize = (size, scriptLevel) => Number(size) / emScale(scriptLevel);
|
|
2830
2811
|
|
|
2831
2812
|
const munderoverNode = (fName, body, below, style) => {
|
|
2832
|
-
const arrowNode =
|
|
2813
|
+
const arrowNode = mathMLnode(fName);
|
|
2833
2814
|
// Is this the short part of a mhchem equilibrium arrow?
|
|
2834
2815
|
const isEq = fName.slice(1, 3) === "eq";
|
|
2835
2816
|
const minWidth = fName.charAt(1) === "x"
|
|
@@ -2868,25 +2849,25 @@ const munderoverNode = (fName, body, below, style) => {
|
|
|
2868
2849
|
// Since Firefox does not support minsize, stack a invisible node
|
|
2869
2850
|
// on top of the label. Its width will serve as a min-width.
|
|
2870
2851
|
// TODO: Refactor this after Firefox supports minsize.
|
|
2871
|
-
upperNode = new
|
|
2852
|
+
upperNode = new MathNode("mover", [label, dummyNode]);
|
|
2872
2853
|
}
|
|
2873
2854
|
const gotLower = (below && below.body &&
|
|
2874
2855
|
(below.body.body || below.body.length > 0));
|
|
2875
2856
|
if (gotLower) {
|
|
2876
2857
|
let label = buildGroup$1(below, labelStyle);
|
|
2877
2858
|
label = paddedNode(label, space, space);
|
|
2878
|
-
lowerNode = new
|
|
2859
|
+
lowerNode = new MathNode("munder", [label, dummyNode]);
|
|
2879
2860
|
}
|
|
2880
2861
|
|
|
2881
2862
|
let node;
|
|
2882
2863
|
if (!gotUpper && !gotLower) {
|
|
2883
|
-
node = new
|
|
2864
|
+
node = new MathNode("mover", [arrowNode, emptyLabel]);
|
|
2884
2865
|
} else if (gotUpper && gotLower) {
|
|
2885
|
-
node = new
|
|
2866
|
+
node = new MathNode("munderover", [arrowNode, lowerNode, upperNode]);
|
|
2886
2867
|
} else if (gotUpper) {
|
|
2887
|
-
node = new
|
|
2868
|
+
node = new MathNode("mover", [arrowNode, upperNode]);
|
|
2888
2869
|
} else {
|
|
2889
|
-
node = new
|
|
2870
|
+
node = new MathNode("munder", [arrowNode, lowerNode]);
|
|
2890
2871
|
}
|
|
2891
2872
|
if (minWidth === "3.0") { node.style.height = "1em"; } // CD environment
|
|
2892
2873
|
node.setAttribute("accent", "false"); // Necessary for MS Word
|
|
@@ -2949,7 +2930,7 @@ defineFunction({
|
|
|
2949
2930
|
const row = [node];
|
|
2950
2931
|
row.unshift(padding(0.2778));
|
|
2951
2932
|
row.push(padding(0.2778));
|
|
2952
|
-
return new
|
|
2933
|
+
return new MathNode("mrow", row)
|
|
2953
2934
|
}
|
|
2954
2935
|
});
|
|
2955
2936
|
|
|
@@ -3002,21 +2983,21 @@ defineFunction({
|
|
|
3002
2983
|
const botArrow = munderoverNode(botLabel, group.lowerArrowBody, group.below, style);
|
|
3003
2984
|
let wrapper;
|
|
3004
2985
|
|
|
3005
|
-
const raiseNode = new
|
|
2986
|
+
const raiseNode = new MathNode("mpadded", [topArrow]);
|
|
3006
2987
|
raiseNode.setAttribute("voffset", "0.3em");
|
|
3007
2988
|
raiseNode.setAttribute("height", "+0.3em");
|
|
3008
2989
|
raiseNode.setAttribute("depth", "-0.3em");
|
|
3009
2990
|
// One of the arrows is given ~zero width. so the other has the same horzontal alignment.
|
|
3010
2991
|
if (group.name === "\\equilibriumLeft") {
|
|
3011
|
-
const botNode = new
|
|
2992
|
+
const botNode = new MathNode("mpadded", [botArrow]);
|
|
3012
2993
|
botNode.setAttribute("width", "0.5em");
|
|
3013
|
-
wrapper = new
|
|
2994
|
+
wrapper = new MathNode(
|
|
3014
2995
|
"mpadded",
|
|
3015
2996
|
[padding(0.2778), botNode, raiseNode, padding(0.2778)]
|
|
3016
2997
|
);
|
|
3017
2998
|
} else {
|
|
3018
2999
|
raiseNode.setAttribute("width", (group.name === "\\equilibriumRight" ? "0.5em" : "0"));
|
|
3019
|
-
wrapper = new
|
|
3000
|
+
wrapper = new MathNode(
|
|
3020
3001
|
"mpadded",
|
|
3021
3002
|
[padding(0.2778), raiseNode, botArrow, padding(0.2778)]
|
|
3022
3003
|
);
|
|
@@ -3308,18 +3289,18 @@ defineFunction({
|
|
|
3308
3289
|
},
|
|
3309
3290
|
mathmlBuilder(group, style) {
|
|
3310
3291
|
if (group.label.body.length === 0) {
|
|
3311
|
-
return new
|
|
3292
|
+
return new MathNode("mrow", style) // empty label
|
|
3312
3293
|
}
|
|
3313
3294
|
// Abuse an <mtable> to create vertically centered content.
|
|
3314
3295
|
const mrow = buildGroup$1(group.label, style);
|
|
3315
3296
|
if (group.side === "left") {
|
|
3316
3297
|
mrow.classes.push("tml-shift-left");
|
|
3317
3298
|
}
|
|
3318
|
-
const mtd = new
|
|
3299
|
+
const mtd = new MathNode("mtd", [mrow]);
|
|
3319
3300
|
mtd.style.padding = "0";
|
|
3320
|
-
const mtr = new
|
|
3321
|
-
const mtable = new
|
|
3322
|
-
const label = new
|
|
3301
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
3302
|
+
const mtable = new MathNode("mtable", [mtr]);
|
|
3303
|
+
const label = new MathNode("mpadded", [mtable]);
|
|
3323
3304
|
// Set the label width to zero so that the arrow will be centered under the corner cell.
|
|
3324
3305
|
label.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
3325
3306
|
label.setAttribute("displaystyle", "false");
|
|
@@ -3342,7 +3323,7 @@ defineFunction({
|
|
|
3342
3323
|
};
|
|
3343
3324
|
},
|
|
3344
3325
|
mathmlBuilder(group, style) {
|
|
3345
|
-
return new
|
|
3326
|
+
return new MathNode("mrow", [buildGroup$1(group.fragment, style)]);
|
|
3346
3327
|
}
|
|
3347
3328
|
});
|
|
3348
3329
|
|
|
@@ -6441,7 +6422,7 @@ const alignMap = {
|
|
|
6441
6422
|
};
|
|
6442
6423
|
|
|
6443
6424
|
const glue = group => {
|
|
6444
|
-
const glueNode = new
|
|
6425
|
+
const glueNode = new MathNode("mtd", []);
|
|
6445
6426
|
glueNode.style = { padding: "0", width: "50%" };
|
|
6446
6427
|
if (group.envClasses.includes("multline")) {
|
|
6447
6428
|
glueNode.style.width = "7.5%";
|
|
@@ -6453,6 +6434,7 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6453
6434
|
const tbl = [];
|
|
6454
6435
|
const numRows = group.body.length;
|
|
6455
6436
|
const hlines = group.hLinesBeforeRow;
|
|
6437
|
+
const tagIsPresent = (group.tags && group.tags.some((tag) => tag));
|
|
6456
6438
|
|
|
6457
6439
|
for (let i = 0; i < numRows; i++) {
|
|
6458
6440
|
const rw = group.body[i];
|
|
@@ -6464,7 +6446,7 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6464
6446
|
: StyleLevel.DISPLAY;
|
|
6465
6447
|
|
|
6466
6448
|
for (let j = 0; j < rw.length; j++) {
|
|
6467
|
-
const mtd = new
|
|
6449
|
+
const mtd = new MathNode(
|
|
6468
6450
|
"mtd",
|
|
6469
6451
|
[buildGroup$1(rw[j], style.withLevel(cellLevel))]
|
|
6470
6452
|
);
|
|
@@ -6480,16 +6462,16 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6480
6462
|
const numColumns = group.body[0].length;
|
|
6481
6463
|
// Fill out a short row with empty <mtd> elements.
|
|
6482
6464
|
for (let k = 0; k < numColumns - rw.length; k++) {
|
|
6483
|
-
row.push(new
|
|
6465
|
+
row.push(new MathNode("mtd", [], [], style));
|
|
6484
6466
|
}
|
|
6485
|
-
if (
|
|
6467
|
+
if (tagIsPresent) {
|
|
6486
6468
|
const tag = group.tags[i];
|
|
6487
6469
|
let tagElement;
|
|
6488
6470
|
if (tag === true) { // automatic numbering
|
|
6489
|
-
tagElement = new
|
|
6471
|
+
tagElement = new MathNode("mtext", [new Span(["tml-eqn"])]);
|
|
6490
6472
|
} else if (tag === false) {
|
|
6491
6473
|
// \nonumber/\notag or starred environment
|
|
6492
|
-
tagElement = new
|
|
6474
|
+
tagElement = new MathNode("mtext", [], []);
|
|
6493
6475
|
} else { // manual \tag
|
|
6494
6476
|
tagElement = buildExpressionRow(tag[0].body, style.withLevel(cellLevel), true);
|
|
6495
6477
|
tagElement = consolidateText(tagElement);
|
|
@@ -6505,7 +6487,7 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6505
6487
|
}
|
|
6506
6488
|
}
|
|
6507
6489
|
}
|
|
6508
|
-
const mtr = new
|
|
6490
|
+
const mtr = new MathNode("mtr", row, []);
|
|
6509
6491
|
const label = group.labels.shift();
|
|
6510
6492
|
if (label && group.tags && group.tags[i]) {
|
|
6511
6493
|
mtr.setAttribute("id", label);
|
|
@@ -6594,7 +6576,7 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6594
6576
|
if (j === numCols - 1 && hand === 1) { return "0" }
|
|
6595
6577
|
if (group.envClasses[0] !== "align") { return sidePadding }
|
|
6596
6578
|
if (hand === 1) { return "0" }
|
|
6597
|
-
if (
|
|
6579
|
+
if (tagIsPresent) {
|
|
6598
6580
|
return (j % 2) ? "1" : "0"
|
|
6599
6581
|
} else {
|
|
6600
6582
|
return (j % 2) ? "0" : "1"
|
|
@@ -6630,7 +6612,7 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6630
6612
|
// TODO: Remove -webkit- when Chromium no longer needs it.
|
|
6631
6613
|
row.children[j].classes = ["tml-" + (j % 2 ? "left" : "right")];
|
|
6632
6614
|
}
|
|
6633
|
-
if (
|
|
6615
|
+
if (tagIsPresent) {
|
|
6634
6616
|
const k = group.leqno ? 0 : row.children.length - 1;
|
|
6635
6617
|
row.children[k].classes = []; // Default is center.
|
|
6636
6618
|
}
|
|
@@ -6647,7 +6629,7 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6647
6629
|
}
|
|
6648
6630
|
}
|
|
6649
6631
|
|
|
6650
|
-
let table = new
|
|
6632
|
+
let table = new MathNode("mtable", tbl);
|
|
6651
6633
|
if (group.envClasses.length > 0) {
|
|
6652
6634
|
// Top & bottom padding
|
|
6653
6635
|
if (group.envClasses.includes("jot")) {
|
|
@@ -6687,7 +6669,7 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6687
6669
|
row.children[0].style.borderLeft = sep;
|
|
6688
6670
|
}
|
|
6689
6671
|
}
|
|
6690
|
-
let iCol =
|
|
6672
|
+
let iCol = tagIsPresent ? 0 : -1;
|
|
6691
6673
|
for (let i = iStart; i < iEnd; i++) {
|
|
6692
6674
|
if (cols[i].type === "align") {
|
|
6693
6675
|
const colAlign = alignMap[cols[i].align];
|
|
@@ -6731,7 +6713,7 @@ const mathmlBuilder$9 = function(group, style) {
|
|
|
6731
6713
|
|
|
6732
6714
|
if (group.envClasses.includes("small")) {
|
|
6733
6715
|
// A small array. Wrap in scriptstyle.
|
|
6734
|
-
table = new
|
|
6716
|
+
table = new MathNode("mstyle", [table]);
|
|
6735
6717
|
table.setAttribute("scriptlevel", "1");
|
|
6736
6718
|
}
|
|
6737
6719
|
|
|
@@ -6978,9 +6960,8 @@ defineEnvironment({
|
|
|
6978
6960
|
numArgs: 0
|
|
6979
6961
|
},
|
|
6980
6962
|
handler(context) {
|
|
6981
|
-
const payload = {
|
|
6963
|
+
const payload = { envClasses: ["small"] };
|
|
6982
6964
|
const res = parseArray(context.parser, payload, "script");
|
|
6983
|
-
res.envClasses = ["small"];
|
|
6984
6965
|
return res;
|
|
6985
6966
|
},
|
|
6986
6967
|
mathmlBuilder: mathmlBuilder$9
|
|
@@ -7214,6 +7195,78 @@ defineFunction({
|
|
|
7214
7195
|
}
|
|
7215
7196
|
});
|
|
7216
7197
|
|
|
7198
|
+
defineFunction({
|
|
7199
|
+
type: "cancelto",
|
|
7200
|
+
names: ["\\cancelto"],
|
|
7201
|
+
props: {
|
|
7202
|
+
numArgs: 2
|
|
7203
|
+
},
|
|
7204
|
+
handler({ parser }, args) {
|
|
7205
|
+
const to = args[0];
|
|
7206
|
+
const body = args[1];
|
|
7207
|
+
return {
|
|
7208
|
+
type: "cancelto",
|
|
7209
|
+
mode: parser.mode,
|
|
7210
|
+
body,
|
|
7211
|
+
to,
|
|
7212
|
+
isCharacterBox: isCharacterBox(body)
|
|
7213
|
+
};
|
|
7214
|
+
},
|
|
7215
|
+
mathmlBuilder(group, style) {
|
|
7216
|
+
const fromNode = new MathNode(
|
|
7217
|
+
"mrow",
|
|
7218
|
+
[buildGroup$1(group.body, style)],
|
|
7219
|
+
["ff-narrow"] // A zero-width mrow.
|
|
7220
|
+
);
|
|
7221
|
+
// Write the arrow in a node written after the content.
|
|
7222
|
+
// That way, the arrow will be an overlay on the content.
|
|
7223
|
+
const phantom = new MathNode("mphantom", [buildGroup$1(group.body, style)]);
|
|
7224
|
+
const arrow = new MathNode("mrow", [phantom], ["tml-cancelto"]);
|
|
7225
|
+
if (group.isCharacterBox && smalls.indexOf(group.body.body[0].text) > -1) {
|
|
7226
|
+
arrow.style.left = "0.1em";
|
|
7227
|
+
arrow.style.width = "90%";
|
|
7228
|
+
}
|
|
7229
|
+
const node = new MathNode("mrow", [fromNode, arrow], ["menclose"]);
|
|
7230
|
+
if (!group.isCharacterBox || /[f∫∑]/.test(group.body.body[0].text)) {
|
|
7231
|
+
// Add 0.2em space to right of content to make room for the arrowhead.
|
|
7232
|
+
phantom.style.paddingRight = "0.2em";
|
|
7233
|
+
} else {
|
|
7234
|
+
phantom.style.padding = "0.5ex 0.1em 0 0";
|
|
7235
|
+
const strut = new MathNode('mspace', []);
|
|
7236
|
+
strut.setAttribute('height', "0.85em");
|
|
7237
|
+
fromNode.children.push(strut);
|
|
7238
|
+
}
|
|
7239
|
+
|
|
7240
|
+
// Create the "to" value above and to the right of the arrow.
|
|
7241
|
+
// First, we want a dummy node with the same height as the `from` content.
|
|
7242
|
+
// We'll place the `to` node above the dummy to get the correct vertical alignment.
|
|
7243
|
+
let dummyNode;
|
|
7244
|
+
if (group.isCharacterBox) {
|
|
7245
|
+
dummyNode = new MathNode('mspace', []);
|
|
7246
|
+
dummyNode.setAttribute('height', "1em");
|
|
7247
|
+
} else {
|
|
7248
|
+
// Create a phantom node with the same content as the body.
|
|
7249
|
+
const inner = buildGroup$1(group.body, style);
|
|
7250
|
+
// The phantom node will be zero-width, so it won't affect horizontal spacing.
|
|
7251
|
+
const zeroWidthNode = new MathNode("mpadded", [inner]);
|
|
7252
|
+
zeroWidthNode.setAttribute("width", "0.1px"); // Don't use 0. WebKit would omit it.
|
|
7253
|
+
dummyNode = new MathNode("mphantom", [zeroWidthNode]); // Hide it.
|
|
7254
|
+
}
|
|
7255
|
+
const toNode = buildGroup$1(group.to, style);
|
|
7256
|
+
const zeroWidthToNode = new MathNode("mpadded", [toNode]);
|
|
7257
|
+
if (!group.isCharacterBox || /[f∫∑]/.test(group.body.body[0].text)) {
|
|
7258
|
+
const w = new MathNode("mspace", []);
|
|
7259
|
+
w.setAttribute('width', "0.2em");
|
|
7260
|
+
zeroWidthToNode.children.unshift(w);
|
|
7261
|
+
}
|
|
7262
|
+
zeroWidthToNode.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
7263
|
+
const mover = new MathNode("mover", [dummyNode, zeroWidthToNode]);
|
|
7264
|
+
// Fix Firefox positioning.
|
|
7265
|
+
const nudgeLeft = new MathNode('mrow', [], ["ff-nudge-left"]);
|
|
7266
|
+
return newDocumentFragment([makeRow([node, mover]), nudgeLeft])
|
|
7267
|
+
}
|
|
7268
|
+
});
|
|
7269
|
+
|
|
7217
7270
|
// \@char is an internal function that takes a grouped decimal argument like
|
|
7218
7271
|
// {123} and converts into symbol with code 123. It is used by the *macro*
|
|
7219
7272
|
// \char defined in macros.js.
|
|
@@ -7397,13 +7450,13 @@ const mathmlBuilder$8 = (group, style) => {
|
|
|
7397
7450
|
// the color individually to each node and return a document fragment.
|
|
7398
7451
|
let expr = buildExpression(group.body, style.withColor(group.color));
|
|
7399
7452
|
if (expr.length === 0) {
|
|
7400
|
-
expr.push(new
|
|
7453
|
+
expr.push(new MathNode("mrow"));
|
|
7401
7454
|
}
|
|
7402
7455
|
expr = expr.map(e => {
|
|
7403
7456
|
e.style.color = group.color;
|
|
7404
7457
|
return e
|
|
7405
7458
|
});
|
|
7406
|
-
return
|
|
7459
|
+
return newDocumentFragment(expr)
|
|
7407
7460
|
};
|
|
7408
7461
|
|
|
7409
7462
|
defineFunction({
|
|
@@ -7524,7 +7577,7 @@ defineFunction({
|
|
|
7524
7577
|
mathmlBuilder(group, style) {
|
|
7525
7578
|
// MathML 3.0 calls for newline to occur in an <mo> or an <mspace>.
|
|
7526
7579
|
// Ref: https://www.w3.org/TR/MathML3/chapter3.html#presm.linebreaking
|
|
7527
|
-
const node = new
|
|
7580
|
+
const node = new MathNode("mo");
|
|
7528
7581
|
if (group.newLine) {
|
|
7529
7582
|
node.setAttribute("linebreak", "newline");
|
|
7530
7583
|
if (group.size) {
|
|
@@ -7979,7 +8032,7 @@ defineFunction({
|
|
|
7979
8032
|
if (group.delim === ".") { group.delim = ""; }
|
|
7980
8033
|
children.push(makeText(group.delim, group.mode));
|
|
7981
8034
|
|
|
7982
|
-
const node = new
|
|
8035
|
+
const node = new MathNode("mo", children);
|
|
7983
8036
|
|
|
7984
8037
|
if (group.mclass === "mopen" || group.mclass === "mclose") {
|
|
7985
8038
|
// Only some of the delimsizing functions act as fences, and they
|
|
@@ -8073,7 +8126,7 @@ defineFunction({
|
|
|
8073
8126
|
const inner = buildExpression(group.body, style);
|
|
8074
8127
|
|
|
8075
8128
|
if (group.left === ".") { group.left = ""; }
|
|
8076
|
-
const leftNode = new
|
|
8129
|
+
const leftNode = new MathNode("mo", [makeText(group.left, group.mode)]);
|
|
8077
8130
|
leftNode.setAttribute("fence", "true");
|
|
8078
8131
|
leftNode.setAttribute("form", "prefix");
|
|
8079
8132
|
if (group.left === "/" || group.left === "\u005C" || group.left.indexOf("arrow") > -1) {
|
|
@@ -8082,7 +8135,7 @@ defineFunction({
|
|
|
8082
8135
|
inner.unshift(leftNode);
|
|
8083
8136
|
|
|
8084
8137
|
if (group.right === ".") { group.right = ""; }
|
|
8085
|
-
const rightNode = new
|
|
8138
|
+
const rightNode = new MathNode("mo", [makeText(group.right, group.mode)]);
|
|
8086
8139
|
rightNode.setAttribute("fence", "true");
|
|
8087
8140
|
rightNode.setAttribute("form", "postfix");
|
|
8088
8141
|
if (group.right === "\u2216" || group.right.indexOf("arrow") > -1) {
|
|
@@ -8124,7 +8177,7 @@ defineFunction({
|
|
|
8124
8177
|
},
|
|
8125
8178
|
mathmlBuilder: (group, style) => {
|
|
8126
8179
|
const textNode = makeText(group.delim, group.mode);
|
|
8127
|
-
const middleNode = new
|
|
8180
|
+
const middleNode = new MathNode("mo", [textNode]);
|
|
8128
8181
|
middleNode.setAttribute("fence", "true");
|
|
8129
8182
|
if (group.delim.indexOf("arrow") > -1) {
|
|
8130
8183
|
middleNode.setAttribute("stretchy", "true");
|
|
@@ -8140,8 +8193,11 @@ defineFunction({
|
|
|
8140
8193
|
}
|
|
8141
8194
|
});
|
|
8142
8195
|
|
|
8196
|
+
const boxTags = ["\\boxed", "\\fcolorbox", "\\colorbox"];
|
|
8197
|
+
|
|
8143
8198
|
const mathmlBuilder$7 = (group, style) => {
|
|
8144
|
-
const
|
|
8199
|
+
const tag = boxTags.includes(group.label) ? "mrow" : "menclose";
|
|
8200
|
+
const node = new MathNode(tag, [buildGroup$1(group.body, style)]);
|
|
8145
8201
|
switch (group.label) {
|
|
8146
8202
|
case "\\overline":
|
|
8147
8203
|
node.setAttribute("notation", "top"); // for Firefox & WebKit
|
|
@@ -8153,34 +8209,35 @@ const mathmlBuilder$7 = (group, style) => {
|
|
|
8153
8209
|
break
|
|
8154
8210
|
case "\\cancel":
|
|
8155
8211
|
node.setAttribute("notation", "updiagonalstrike");
|
|
8156
|
-
node.children.push(new
|
|
8212
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "upstrike"]));
|
|
8157
8213
|
break
|
|
8158
8214
|
case "\\bcancel":
|
|
8159
8215
|
node.setAttribute("notation", "downdiagonalstrike");
|
|
8160
|
-
node.children.push(new
|
|
8216
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "downstrike"]));
|
|
8161
8217
|
break
|
|
8162
8218
|
case "\\sout":
|
|
8163
8219
|
node.setAttribute("notation", "horizontalstrike");
|
|
8164
|
-
node.children.push(new
|
|
8220
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "sout"]));
|
|
8165
8221
|
break
|
|
8166
8222
|
case "\\xcancel":
|
|
8167
8223
|
node.setAttribute("notation", "updiagonalstrike downdiagonalstrike");
|
|
8168
8224
|
node.classes.push("tml-xcancel");
|
|
8169
8225
|
break
|
|
8226
|
+
// cancelto is handled in cancelto.js
|
|
8170
8227
|
case "\\longdiv":
|
|
8171
8228
|
node.setAttribute("notation", "longdiv");
|
|
8172
8229
|
node.classes.push("longdiv-top");
|
|
8173
|
-
node.children.push(new
|
|
8230
|
+
node.children.push(new MathNode("mrow", [], ["longdiv-arc"]));
|
|
8174
8231
|
break
|
|
8175
8232
|
case "\\phase":
|
|
8176
8233
|
node.setAttribute("notation", "phasorangle");
|
|
8177
8234
|
node.classes.push("phasor-bottom");
|
|
8178
|
-
node.children.push(new
|
|
8235
|
+
node.children.push(new MathNode("mrow", [], ["phasor-angle"]));
|
|
8179
8236
|
break
|
|
8180
8237
|
case "\\textcircled":
|
|
8181
8238
|
node.setAttribute("notation", "circle");
|
|
8182
8239
|
node.classes.push("circle-pad");
|
|
8183
|
-
node.children.push(new
|
|
8240
|
+
node.children.push(new MathNode("mrow", [], ["textcircle"]));
|
|
8184
8241
|
break
|
|
8185
8242
|
case "\\angl":
|
|
8186
8243
|
node.setAttribute("notation", "actuarial");
|
|
@@ -8188,7 +8245,6 @@ const mathmlBuilder$7 = (group, style) => {
|
|
|
8188
8245
|
break
|
|
8189
8246
|
case "\\boxed":
|
|
8190
8247
|
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
|
|
8191
|
-
node.setAttribute("notation", "box");
|
|
8192
8248
|
node.style.padding = "3pt";
|
|
8193
8249
|
node.style.border = "1px solid";
|
|
8194
8250
|
node.setAttribute("scriptlevel", "0");
|
|
@@ -8200,13 +8256,8 @@ const mathmlBuilder$7 = (group, style) => {
|
|
|
8200
8256
|
break
|
|
8201
8257
|
case "\\fcolorbox":
|
|
8202
8258
|
case "\\colorbox": {
|
|
8203
|
-
//
|
|
8204
|
-
//
|
|
8205
|
-
// included with <menclose>.
|
|
8206
|
-
//const fboxsep = 3; // 3 pt from LaTeX source2e
|
|
8207
|
-
//node.setAttribute("height", `+${2 * fboxsep}pt`)
|
|
8208
|
-
//node.setAttribute("voffset", `${fboxsep}pt`)
|
|
8209
|
-
node.style.padding = "3pt";
|
|
8259
|
+
// Don't use <menclose>. WebKit would show a radical.
|
|
8260
|
+
node.style.padding = "0.3em"; // 3 pt from LaTeX source2e for a 10pt font
|
|
8210
8261
|
if (group.label === "\\fcolorbox") {
|
|
8211
8262
|
node.style.border = "0.0667em solid " + String(group.borderColor);
|
|
8212
8263
|
}
|
|
@@ -8432,7 +8483,7 @@ defineFunction({
|
|
|
8432
8483
|
};
|
|
8433
8484
|
},
|
|
8434
8485
|
mathmlBuilder(group, style) {
|
|
8435
|
-
return new
|
|
8486
|
+
return new MathNode("mrow");
|
|
8436
8487
|
}
|
|
8437
8488
|
});
|
|
8438
8489
|
|
|
@@ -8449,7 +8500,7 @@ defineFunction({
|
|
|
8449
8500
|
};
|
|
8450
8501
|
},
|
|
8451
8502
|
mathmlBuilder(group, style) {
|
|
8452
|
-
return new
|
|
8503
|
+
return new MathNode("mrow");
|
|
8453
8504
|
}
|
|
8454
8505
|
});
|
|
8455
8506
|
|
|
@@ -8492,7 +8543,7 @@ const mathmlBuilder$6 = (group, style) => {
|
|
|
8492
8543
|
: mathGroup.children[i].children[0].text;
|
|
8493
8544
|
}
|
|
8494
8545
|
// Wrap in a <mpadded> to prevent the same Firefox bug.
|
|
8495
|
-
const mpadded = new
|
|
8546
|
+
const mpadded = new MathNode("mpadded", [mi]);
|
|
8496
8547
|
mpadded.setAttribute("lspace", "0");
|
|
8497
8548
|
return mpadded
|
|
8498
8549
|
}
|
|
@@ -8518,8 +8569,8 @@ const mathmlBuilder$6 = (group, style) => {
|
|
|
8518
8569
|
// Ref: https://bugs.webkit.org/show_bug.cgi?id=129097
|
|
8519
8570
|
// We insert a text node that contains a zero-width space and wrap in an mrow.
|
|
8520
8571
|
// TODO: Get rid of this <mi> workaround when the Firefox bug is fixed.
|
|
8521
|
-
const bogus = new
|
|
8522
|
-
return new
|
|
8572
|
+
const bogus = new MathNode("mtext", new TextNode("\u200b"));
|
|
8573
|
+
return new MathNode("mrow", [bogus, mi])
|
|
8523
8574
|
}
|
|
8524
8575
|
return mi
|
|
8525
8576
|
};
|
|
@@ -8630,7 +8681,7 @@ const mathmlBuilder$5 = (group, style) => {
|
|
|
8630
8681
|
denom.setAttribute("scriptlevel", "2");
|
|
8631
8682
|
}
|
|
8632
8683
|
|
|
8633
|
-
let node = new
|
|
8684
|
+
let node = new MathNode("mfrac", [numer, denom]);
|
|
8634
8685
|
|
|
8635
8686
|
if (!group.hasBarLine) {
|
|
8636
8687
|
node.setAttribute("linethickness", "0px");
|
|
@@ -8643,8 +8694,8 @@ const mathmlBuilder$5 = (group, style) => {
|
|
|
8643
8694
|
const withDelims = [];
|
|
8644
8695
|
|
|
8645
8696
|
if (group.leftDelim != null) {
|
|
8646
|
-
const leftOp = new
|
|
8647
|
-
new
|
|
8697
|
+
const leftOp = new MathNode("mo", [
|
|
8698
|
+
new TextNode(group.leftDelim.replace("\\", ""))
|
|
8648
8699
|
]);
|
|
8649
8700
|
leftOp.setAttribute("fence", "true");
|
|
8650
8701
|
withDelims.push(leftOp);
|
|
@@ -8653,8 +8704,8 @@ const mathmlBuilder$5 = (group, style) => {
|
|
|
8653
8704
|
withDelims.push(node);
|
|
8654
8705
|
|
|
8655
8706
|
if (group.rightDelim != null) {
|
|
8656
|
-
const rightOp = new
|
|
8657
|
-
new
|
|
8707
|
+
const rightOp = new MathNode("mo", [
|
|
8708
|
+
new TextNode(group.rightDelim.replace("\\", ""))
|
|
8658
8709
|
]);
|
|
8659
8710
|
rightOp.setAttribute("fence", "true");
|
|
8660
8711
|
withDelims.push(rightOp);
|
|
@@ -8664,7 +8715,7 @@ const mathmlBuilder$5 = (group, style) => {
|
|
|
8664
8715
|
}
|
|
8665
8716
|
|
|
8666
8717
|
if (group.scriptLevel !== "auto") {
|
|
8667
|
-
node = new
|
|
8718
|
+
node = new MathNode("mstyle", [node]);
|
|
8668
8719
|
node.setAttribute("displaystyle", String(group.scriptLevel === "display"));
|
|
8669
8720
|
node.setAttribute("scriptlevel", scriptLevel[group.scriptLevel]);
|
|
8670
8721
|
}
|
|
@@ -8967,24 +9018,24 @@ defineFunction({
|
|
|
8967
9018
|
});
|
|
8968
9019
|
|
|
8969
9020
|
const mathmlBuilder$4 = (group, style) => {
|
|
8970
|
-
const accentNode =
|
|
9021
|
+
const accentNode = mathMLnode(group.label);
|
|
8971
9022
|
accentNode.style["math-depth"] = 0;
|
|
8972
|
-
return new
|
|
9023
|
+
return new MathNode(group.isOver ? "mover" : "munder", [
|
|
8973
9024
|
buildGroup$1(group.base, style),
|
|
8974
9025
|
accentNode
|
|
8975
9026
|
]);
|
|
8976
9027
|
};
|
|
8977
9028
|
|
|
8978
|
-
// Horizontal stretchy
|
|
9029
|
+
// Horizontal stretchy brackets
|
|
8979
9030
|
defineFunction({
|
|
8980
|
-
type: "
|
|
8981
|
-
names: ["\\overbrace", "\\underbrace"],
|
|
9031
|
+
type: "horizBracket",
|
|
9032
|
+
names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"],
|
|
8982
9033
|
props: {
|
|
8983
9034
|
numArgs: 1
|
|
8984
9035
|
},
|
|
8985
9036
|
handler({ parser, funcName }, args) {
|
|
8986
9037
|
return {
|
|
8987
|
-
type: "
|
|
9038
|
+
type: "horizBracket",
|
|
8988
9039
|
mode: parser.mode,
|
|
8989
9040
|
label: funcName,
|
|
8990
9041
|
isOver: /^\\over/.test(funcName),
|
|
@@ -9205,7 +9256,7 @@ defineFunction({
|
|
|
9205
9256
|
const node = new Img(group.src, group.alt, graphicStyle);
|
|
9206
9257
|
node.height = height;
|
|
9207
9258
|
node.depth = depth;
|
|
9208
|
-
return new
|
|
9259
|
+
return new MathNode("mtext", [node])
|
|
9209
9260
|
}
|
|
9210
9261
|
});
|
|
9211
9262
|
|
|
@@ -9255,17 +9306,17 @@ defineFunction({
|
|
|
9255
9306
|
? spaceCharacter(dimension.number)
|
|
9256
9307
|
: "";
|
|
9257
9308
|
if (group.mode === "text" && ch.length > 0) {
|
|
9258
|
-
const character = new
|
|
9259
|
-
return new
|
|
9309
|
+
const character = new TextNode(ch);
|
|
9310
|
+
return new MathNode("mtext", [character]);
|
|
9260
9311
|
} else {
|
|
9261
9312
|
if (dimension.number >= 0) {
|
|
9262
|
-
const node = new
|
|
9313
|
+
const node = new MathNode("mspace");
|
|
9263
9314
|
node.setAttribute("width", dimension.number + dimension.unit);
|
|
9264
9315
|
return node
|
|
9265
9316
|
} else {
|
|
9266
9317
|
// Don't use <mspace> or <mpadded> because
|
|
9267
9318
|
// WebKit recognizes negative left margin only on a <mrow> element
|
|
9268
|
-
const node = new
|
|
9319
|
+
const node = new MathNode("mrow");
|
|
9269
9320
|
node.style.marginLeft = dimension.number + dimension.unit;
|
|
9270
9321
|
return node
|
|
9271
9322
|
}
|
|
@@ -9306,7 +9357,7 @@ defineFunction({
|
|
|
9306
9357
|
},
|
|
9307
9358
|
mathmlBuilder(group, style) {
|
|
9308
9359
|
// Return a no-width, no-ink element with an HTML id.
|
|
9309
|
-
const node = new
|
|
9360
|
+
const node = new MathNode("mrow", [], ["tml-label"]);
|
|
9310
9361
|
if (group.string.length > 0) {
|
|
9311
9362
|
node.setLabel(group.string);
|
|
9312
9363
|
}
|
|
@@ -9350,8 +9401,8 @@ defineFunction({
|
|
|
9350
9401
|
// We need an invisible strut with the same depth as the group.
|
|
9351
9402
|
// We can't just read the depth, so we use \vphantom methods.
|
|
9352
9403
|
const phantomInner = buildExpression(ordargument(group.body), style);
|
|
9353
|
-
const phantom = new
|
|
9354
|
-
strut = new
|
|
9404
|
+
const phantom = new MathNode("mphantom", phantomInner);
|
|
9405
|
+
strut = new MathNode("mpadded", [phantom]);
|
|
9355
9406
|
strut.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
9356
9407
|
}
|
|
9357
9408
|
|
|
@@ -9361,9 +9412,9 @@ defineFunction({
|
|
|
9361
9412
|
inner.style.position = "absolute";
|
|
9362
9413
|
inner.style.right = "0";
|
|
9363
9414
|
inner.style.bottom = `0`; // If we could have read the ink depth, it would go here.
|
|
9364
|
-
node = new
|
|
9415
|
+
node = new MathNode("mpadded", [strut, inner]);
|
|
9365
9416
|
} else {
|
|
9366
|
-
node = new
|
|
9417
|
+
node = new MathNode("mpadded", [inner]);
|
|
9367
9418
|
}
|
|
9368
9419
|
|
|
9369
9420
|
if (group.alignment === "rlap") {
|
|
@@ -9469,7 +9520,7 @@ function mathmlBuilder$3(group, style) {
|
|
|
9469
9520
|
const inner = buildExpression(group.body, style);
|
|
9470
9521
|
|
|
9471
9522
|
if (group.mclass === "minner") {
|
|
9472
|
-
node = new
|
|
9523
|
+
node = new MathNode("mpadded", inner);
|
|
9473
9524
|
} else if (group.mclass === "mord") {
|
|
9474
9525
|
if (group.isCharacterBox || inner[0].type === "mathord") {
|
|
9475
9526
|
node = inner[0];
|
|
@@ -9478,10 +9529,10 @@ function mathmlBuilder$3(group, style) {
|
|
|
9478
9529
|
node.setAttribute("mathvariant", "normal");
|
|
9479
9530
|
}
|
|
9480
9531
|
} else {
|
|
9481
|
-
node = new
|
|
9532
|
+
node = new MathNode("mi", inner);
|
|
9482
9533
|
}
|
|
9483
9534
|
} else {
|
|
9484
|
-
node = new
|
|
9535
|
+
node = new MathNode("mrow", inner);
|
|
9485
9536
|
if (group.mustPromote) {
|
|
9486
9537
|
node = inner[0];
|
|
9487
9538
|
node.type = "mo";
|
|
@@ -9489,7 +9540,7 @@ function mathmlBuilder$3(group, style) {
|
|
|
9489
9540
|
node.setAttribute("mathvariant", "italic");
|
|
9490
9541
|
}
|
|
9491
9542
|
} else {
|
|
9492
|
-
node = new
|
|
9543
|
+
node = new MathNode("mrow", inner);
|
|
9493
9544
|
}
|
|
9494
9545
|
|
|
9495
9546
|
// Set spacing based on what is the most likely adjacent atom type.
|
|
@@ -9559,7 +9610,7 @@ defineFunction({
|
|
|
9559
9610
|
},
|
|
9560
9611
|
handler({ parser, funcName }, args) {
|
|
9561
9612
|
const body = args[0];
|
|
9562
|
-
const isCharacterBox =
|
|
9613
|
+
const isCharacterBox$1 = isCharacterBox(body);
|
|
9563
9614
|
// We should not wrap a <mo> around a <mi> or <mord>. That would be invalid MathML.
|
|
9564
9615
|
// In that case, we instead promote the text contents of the body to the parent.
|
|
9565
9616
|
let mustPromote = true;
|
|
@@ -9588,7 +9639,7 @@ defineFunction({
|
|
|
9588
9639
|
mode: parser.mode,
|
|
9589
9640
|
mclass: "m" + funcName.slice(5),
|
|
9590
9641
|
body: ordargument(mustPromote ? mord : body),
|
|
9591
|
-
isCharacterBox,
|
|
9642
|
+
isCharacterBox: isCharacterBox$1,
|
|
9592
9643
|
mustPromote
|
|
9593
9644
|
};
|
|
9594
9645
|
}
|
|
@@ -9625,7 +9676,7 @@ defineFunction({
|
|
|
9625
9676
|
mode: parser.mode,
|
|
9626
9677
|
mclass: binrelClass(args[0]),
|
|
9627
9678
|
body: ordargument(args[1]),
|
|
9628
|
-
isCharacterBox:
|
|
9679
|
+
isCharacterBox: isCharacterBox(args[1])
|
|
9629
9680
|
};
|
|
9630
9681
|
}
|
|
9631
9682
|
});
|
|
@@ -9739,8 +9790,8 @@ defineFunction({
|
|
|
9739
9790
|
mathmlBuilder(group, style) {
|
|
9740
9791
|
const base = buildGroup$1(group.base, style);
|
|
9741
9792
|
|
|
9742
|
-
const prescriptsNode = new
|
|
9743
|
-
const noneNode = new
|
|
9793
|
+
const prescriptsNode = new MathNode("mprescripts");
|
|
9794
|
+
const noneNode = new MathNode("none");
|
|
9744
9795
|
let children = [];
|
|
9745
9796
|
|
|
9746
9797
|
const preSub = buildGroup(group.prescripts.sub, style, noneNode);
|
|
@@ -9759,7 +9810,7 @@ defineFunction({
|
|
|
9759
9810
|
children = [base, prescriptsNode, preSub, preSup];
|
|
9760
9811
|
}
|
|
9761
9812
|
|
|
9762
|
-
return new
|
|
9813
|
+
return new MathNode("mmultiscripts", children);
|
|
9763
9814
|
}
|
|
9764
9815
|
});
|
|
9765
9816
|
|
|
@@ -9772,9 +9823,9 @@ defineFunction({
|
|
|
9772
9823
|
allowedInText: false
|
|
9773
9824
|
},
|
|
9774
9825
|
handler({ parser }, args) {
|
|
9775
|
-
const isCharacterBox =
|
|
9826
|
+
const isCharacterBox$1 = isCharacterBox(args[0]);
|
|
9776
9827
|
let body;
|
|
9777
|
-
if (isCharacterBox) {
|
|
9828
|
+
if (isCharacterBox$1) {
|
|
9778
9829
|
body = ordargument(args[0]);
|
|
9779
9830
|
if (body[0].text.charAt(0) === "\\") {
|
|
9780
9831
|
body[0].text = symbols.math[body[0].text].replace;
|
|
@@ -9792,7 +9843,7 @@ defineFunction({
|
|
|
9792
9843
|
type: "not",
|
|
9793
9844
|
mode: parser.mode,
|
|
9794
9845
|
body,
|
|
9795
|
-
isCharacterBox
|
|
9846
|
+
isCharacterBox: isCharacterBox$1
|
|
9796
9847
|
};
|
|
9797
9848
|
},
|
|
9798
9849
|
mathmlBuilder(group, style) {
|
|
@@ -10140,7 +10191,8 @@ defineFunction({
|
|
|
10140
10191
|
"\u2a1a"
|
|
10141
10192
|
],
|
|
10142
10193
|
props: {
|
|
10143
|
-
numArgs: 0
|
|
10194
|
+
numArgs: 0,
|
|
10195
|
+
allowedInArgument: true
|
|
10144
10196
|
},
|
|
10145
10197
|
handler({ parser, funcName }) {
|
|
10146
10198
|
let fName = funcName;
|
|
@@ -10171,9 +10223,9 @@ const mathmlBuilder$1 = (group, style) => {
|
|
|
10171
10223
|
let isAllString = true; // default
|
|
10172
10224
|
for (let i = 0; i < expression.length; i++) {
|
|
10173
10225
|
let node = expression[i];
|
|
10174
|
-
if (node instanceof
|
|
10226
|
+
if (node instanceof MathNode) {
|
|
10175
10227
|
if ((node.type === "mrow" || node.type === "mpadded") && node.children.length === 1 &&
|
|
10176
|
-
node.children[0] instanceof
|
|
10228
|
+
node.children[0] instanceof MathNode) {
|
|
10177
10229
|
node = node.children[0];
|
|
10178
10230
|
}
|
|
10179
10231
|
switch (node.type) {
|
|
@@ -10190,14 +10242,14 @@ const mathmlBuilder$1 = (group, style) => {
|
|
|
10190
10242
|
if (ch === "") {
|
|
10191
10243
|
isAllString = false;
|
|
10192
10244
|
} else {
|
|
10193
|
-
expression[i] = new
|
|
10245
|
+
expression[i] = new MathNode("mtext", [new TextNode(ch)]);
|
|
10194
10246
|
}
|
|
10195
10247
|
}
|
|
10196
10248
|
}
|
|
10197
10249
|
break
|
|
10198
10250
|
case "mo": {
|
|
10199
10251
|
const child = node.children[0];
|
|
10200
|
-
if (node.children.length === 1 && child instanceof
|
|
10252
|
+
if (node.children.length === 1 && child instanceof TextNode) {
|
|
10201
10253
|
child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
|
|
10202
10254
|
} else {
|
|
10203
10255
|
isAllString = false;
|
|
@@ -10215,7 +10267,7 @@ const mathmlBuilder$1 = (group, style) => {
|
|
|
10215
10267
|
if (isAllString) {
|
|
10216
10268
|
// Write a single TextNode instead of multiple nested tags.
|
|
10217
10269
|
const word = expression.map((node) => node.toText()).join("");
|
|
10218
|
-
expression = [new
|
|
10270
|
+
expression = [new TextNode(word)];
|
|
10219
10271
|
} else if (
|
|
10220
10272
|
expression.length === 1
|
|
10221
10273
|
&& ["mover", "munder"].includes(expression[0].type) &&
|
|
@@ -10223,41 +10275,41 @@ const mathmlBuilder$1 = (group, style) => {
|
|
|
10223
10275
|
) {
|
|
10224
10276
|
expression[0].children[0].type = "mi";
|
|
10225
10277
|
if (group.parentIsSupSub) {
|
|
10226
|
-
return new
|
|
10278
|
+
return new MathNode("mrow", expression)
|
|
10227
10279
|
} else {
|
|
10228
|
-
const operator = new
|
|
10229
|
-
return
|
|
10280
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
10281
|
+
return newDocumentFragment([expression[0], operator])
|
|
10230
10282
|
}
|
|
10231
10283
|
}
|
|
10232
10284
|
|
|
10233
10285
|
let wrapper;
|
|
10234
10286
|
if (isAllString) {
|
|
10235
|
-
wrapper = new
|
|
10287
|
+
wrapper = new MathNode("mi", expression);
|
|
10236
10288
|
if (expression[0].text.length === 1) {
|
|
10237
10289
|
wrapper.setAttribute("mathvariant", "normal");
|
|
10238
10290
|
}
|
|
10239
10291
|
} else {
|
|
10240
|
-
wrapper = new
|
|
10292
|
+
wrapper = new MathNode("mrow", expression);
|
|
10241
10293
|
}
|
|
10242
10294
|
|
|
10243
10295
|
if (!group.parentIsSupSub) {
|
|
10244
10296
|
// Append an <mo>⁡</mo>.
|
|
10245
10297
|
// ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
|
|
10246
|
-
const operator = new
|
|
10298
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
10247
10299
|
const fragment = [wrapper, operator];
|
|
10248
10300
|
if (group.needsLeadingSpace) {
|
|
10249
10301
|
// LaTeX gives operator spacing, but a <mi> gets ord spacing.
|
|
10250
10302
|
// So add a leading space.
|
|
10251
|
-
const space = new
|
|
10303
|
+
const space = new MathNode("mspace");
|
|
10252
10304
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
10253
10305
|
fragment.unshift(space);
|
|
10254
10306
|
}
|
|
10255
10307
|
if (!group.isFollowedByDelimiter) {
|
|
10256
|
-
const trail = new
|
|
10308
|
+
const trail = new MathNode("mspace");
|
|
10257
10309
|
trail.setAttribute("width", "0.1667em"); // thin space.
|
|
10258
10310
|
fragment.push(trail);
|
|
10259
10311
|
}
|
|
10260
|
-
return
|
|
10312
|
+
return newDocumentFragment(fragment)
|
|
10261
10313
|
}
|
|
10262
10314
|
|
|
10263
10315
|
return wrapper
|
|
@@ -10317,7 +10369,7 @@ defineFunction({
|
|
|
10317
10369
|
},
|
|
10318
10370
|
mathmlBuilder: (group, style) => {
|
|
10319
10371
|
const inner = buildExpression(group.body, style);
|
|
10320
|
-
return new
|
|
10372
|
+
return new MathNode("mphantom", inner);
|
|
10321
10373
|
}
|
|
10322
10374
|
});
|
|
10323
10375
|
|
|
@@ -10338,8 +10390,8 @@ defineFunction({
|
|
|
10338
10390
|
},
|
|
10339
10391
|
mathmlBuilder: (group, style) => {
|
|
10340
10392
|
const inner = buildExpression(ordargument(group.body), style);
|
|
10341
|
-
const phantom = new
|
|
10342
|
-
const node = new
|
|
10393
|
+
const phantom = new MathNode("mphantom", inner);
|
|
10394
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
10343
10395
|
node.setAttribute("height", "0px");
|
|
10344
10396
|
node.setAttribute("depth", "0px");
|
|
10345
10397
|
return node;
|
|
@@ -10363,8 +10415,8 @@ defineFunction({
|
|
|
10363
10415
|
},
|
|
10364
10416
|
mathmlBuilder: (group, style) => {
|
|
10365
10417
|
const inner = buildExpression(ordargument(group.body), style);
|
|
10366
|
-
const phantom = new
|
|
10367
|
-
const node = new
|
|
10418
|
+
const phantom = new MathNode("mphantom", inner);
|
|
10419
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
10368
10420
|
node.setAttribute("width", "0px");
|
|
10369
10421
|
return node;
|
|
10370
10422
|
}
|
|
@@ -10401,7 +10453,7 @@ defineFunction({
|
|
|
10401
10453
|
|
|
10402
10454
|
const mathmlBuilder = (group, style) => {
|
|
10403
10455
|
const newStyle = style.withLevel(StyleLevel.TEXT);
|
|
10404
|
-
const node = new
|
|
10456
|
+
const node = new MathNode("mpadded", [buildGroup$1(group.body, newStyle)]);
|
|
10405
10457
|
const dy = calculateSize(group.dy, style);
|
|
10406
10458
|
node.setAttribute("voffset", dy.number + dy.unit);
|
|
10407
10459
|
// Add padding, which acts to increase height in Chromium.
|
|
@@ -10549,7 +10601,7 @@ defineFunction({
|
|
|
10549
10601
|
: { number: 0, unit: "em" };
|
|
10550
10602
|
const color = (style.color && style.getColor()) || "black";
|
|
10551
10603
|
|
|
10552
|
-
const rule = new
|
|
10604
|
+
const rule = new MathNode("mspace");
|
|
10553
10605
|
if (width.number > 0 && height.number > 0) {
|
|
10554
10606
|
rule.setAttribute("mathbackground", color);
|
|
10555
10607
|
}
|
|
@@ -10557,7 +10609,7 @@ defineFunction({
|
|
|
10557
10609
|
rule.setAttribute("height", height.number + height.unit);
|
|
10558
10610
|
if (shift.number === 0) { return rule }
|
|
10559
10611
|
|
|
10560
|
-
const wrapper = new
|
|
10612
|
+
const wrapper = new MathNode("mpadded", [rule]);
|
|
10561
10613
|
if (shift.number >= 0) {
|
|
10562
10614
|
wrapper.setAttribute("height", "+" + shift.number + shift.unit);
|
|
10563
10615
|
} else {
|
|
@@ -10629,8 +10681,8 @@ defineFunction({
|
|
|
10629
10681
|
const numerator = group.numerator.split('').map(c => unicodeNumSups[c]).join('');
|
|
10630
10682
|
const denominator = group.denominator.split('').map(c => unicodeNumSubs[c]).join('');
|
|
10631
10683
|
// Use a fraction slash.
|
|
10632
|
-
const text = new
|
|
10633
|
-
return new
|
|
10684
|
+
const text = new TextNode(numerator + "\u2044" + denominator, group.mode, style);
|
|
10685
|
+
return new MathNode("mn", [text], ["special-fraction"])
|
|
10634
10686
|
}
|
|
10635
10687
|
});
|
|
10636
10688
|
|
|
@@ -10743,7 +10795,7 @@ defineFunction({
|
|
|
10743
10795
|
};
|
|
10744
10796
|
},
|
|
10745
10797
|
mathmlBuilder: (group, style) => {
|
|
10746
|
-
const node = new
|
|
10798
|
+
const node = new MathNode("mpadded", [buildGroup$1(group.body, style)]);
|
|
10747
10799
|
|
|
10748
10800
|
if (group.smashHeight) {
|
|
10749
10801
|
node.setAttribute("height", "0px");
|
|
@@ -10796,11 +10848,11 @@ defineFunction({
|
|
|
10796
10848
|
mathmlBuilder(group, style) {
|
|
10797
10849
|
const { body, index } = group;
|
|
10798
10850
|
return index
|
|
10799
|
-
? new
|
|
10851
|
+
? new MathNode("mroot", [
|
|
10800
10852
|
buildGroup$1(body, style),
|
|
10801
10853
|
buildGroup$1(index, style.incrementLevel())
|
|
10802
10854
|
])
|
|
10803
|
-
: new
|
|
10855
|
+
: new MathNode("msqrt", [buildGroup$1(body, style)]);
|
|
10804
10856
|
}
|
|
10805
10857
|
});
|
|
10806
10858
|
|
|
@@ -10880,18 +10932,18 @@ const largePad = "AJdfΔΛ";
|
|
|
10880
10932
|
defineFunctionBuilders({
|
|
10881
10933
|
type: "supsub",
|
|
10882
10934
|
mathmlBuilder(group, style) {
|
|
10883
|
-
// Is the inner group a relevant horizontal brace?
|
|
10884
|
-
let
|
|
10935
|
+
// Is the inner group a relevant horizontal brace or bracket?
|
|
10936
|
+
let isBracket = false;
|
|
10885
10937
|
let isOver;
|
|
10886
10938
|
let isSup;
|
|
10887
10939
|
let appendApplyFunction = false;
|
|
10888
10940
|
let appendSpace = false;
|
|
10889
10941
|
let needsLeadingSpace = false;
|
|
10890
10942
|
|
|
10891
|
-
if (group.base && group.base.type === "
|
|
10943
|
+
if (group.base && group.base.type === "horizBracket") {
|
|
10892
10944
|
isSup = !!group.sup;
|
|
10893
10945
|
if (isSup === group.base.isOver) {
|
|
10894
|
-
|
|
10946
|
+
isBracket = true;
|
|
10895
10947
|
isOver = group.base.isOver;
|
|
10896
10948
|
}
|
|
10897
10949
|
}
|
|
@@ -10939,7 +10991,7 @@ defineFunctionBuilders({
|
|
|
10939
10991
|
}
|
|
10940
10992
|
|
|
10941
10993
|
let nodeType;
|
|
10942
|
-
if (
|
|
10994
|
+
if (isBracket) {
|
|
10943
10995
|
nodeType = isOver ? "mover" : "munder";
|
|
10944
10996
|
} else if (!group.sub) {
|
|
10945
10997
|
const base = group.base;
|
|
@@ -10999,26 +11051,26 @@ defineFunctionBuilders({
|
|
|
10999
11051
|
}
|
|
11000
11052
|
}
|
|
11001
11053
|
|
|
11002
|
-
let node = new
|
|
11054
|
+
let node = new MathNode(nodeType, children);
|
|
11003
11055
|
if (appendApplyFunction) {
|
|
11004
11056
|
// Append an <mo>⁡</mo>.
|
|
11005
11057
|
// ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
|
|
11006
|
-
const operator = new
|
|
11058
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
11007
11059
|
if (needsLeadingSpace) {
|
|
11008
|
-
const space = new
|
|
11060
|
+
const space = new MathNode("mspace");
|
|
11009
11061
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
11010
|
-
node =
|
|
11062
|
+
node = newDocumentFragment([space, node, operator]);
|
|
11011
11063
|
} else {
|
|
11012
|
-
node =
|
|
11064
|
+
node = newDocumentFragment([node, operator]);
|
|
11013
11065
|
}
|
|
11014
11066
|
if (appendSpace) {
|
|
11015
|
-
const space = new
|
|
11067
|
+
const space = new MathNode("mspace");
|
|
11016
11068
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
11017
11069
|
node.children.push(space);
|
|
11018
11070
|
}
|
|
11019
11071
|
} else if (symbolRegEx.test(nodeType)) {
|
|
11020
11072
|
// Wrap in a <mrow>. Otherwise Firefox stretchy parens will not stretch to include limits.
|
|
11021
|
-
node = new
|
|
11073
|
+
node = new MathNode("mrow", [node]);
|
|
11022
11074
|
}
|
|
11023
11075
|
|
|
11024
11076
|
return node
|
|
@@ -11043,7 +11095,7 @@ const isArrow = str => {
|
|
|
11043
11095
|
defineFunctionBuilders({
|
|
11044
11096
|
type: "atom",
|
|
11045
11097
|
mathmlBuilder(group, style) {
|
|
11046
|
-
const node = new
|
|
11098
|
+
const node = new MathNode("mo", [makeText(group.text, group.mode)]);
|
|
11047
11099
|
if (group.family === "punct") {
|
|
11048
11100
|
node.setAttribute("separator", "true");
|
|
11049
11101
|
} else if (group.family === "open" || group.family === "close") {
|
|
@@ -11073,10 +11125,10 @@ defineFunctionBuilders({
|
|
|
11073
11125
|
} else if (group.needsSpacing) {
|
|
11074
11126
|
// Fix a MathML bug that occurs when a <mo> is between two <mtext> elements.
|
|
11075
11127
|
if (group.family === "bin") {
|
|
11076
|
-
return new
|
|
11128
|
+
return new MathNode("mrow", [padding(0.222), node, padding(0.222)])
|
|
11077
11129
|
} else {
|
|
11078
11130
|
// REL spacing
|
|
11079
|
-
return new
|
|
11131
|
+
return new MathNode("mrow", [padding(0.2778), node, padding(0.2778)])
|
|
11080
11132
|
}
|
|
11081
11133
|
}
|
|
11082
11134
|
return node;
|
|
@@ -11417,8 +11469,8 @@ const primes = new Set(["\\prime", "\\dprime", "\\trprime", "\\qprime",
|
|
|
11417
11469
|
"\\backprime", "\\backdprime", "\\backtrprime"]);
|
|
11418
11470
|
|
|
11419
11471
|
const italicNumber = (text, variant, tag) => {
|
|
11420
|
-
const mn = new
|
|
11421
|
-
const wrapper = new
|
|
11472
|
+
const mn = new MathNode(tag, [text]);
|
|
11473
|
+
const wrapper = new MathNode("mstyle", [mn]);
|
|
11422
11474
|
wrapper.style["font-style"] = "italic";
|
|
11423
11475
|
wrapper.style["font-family"] = "Cambria, 'Times New Roman', serif";
|
|
11424
11476
|
if (variant === "bold-italic") { wrapper.style["font-weight"] = "bold"; }
|
|
@@ -11435,17 +11487,17 @@ defineFunctionBuilders({
|
|
|
11435
11487
|
const variant = getVariant(group, style) || defaultVariant;
|
|
11436
11488
|
if (variant === "script") {
|
|
11437
11489
|
text.text = variantChar(text.text, variant);
|
|
11438
|
-
return new
|
|
11490
|
+
return new MathNode("mi", [text], [style.font])
|
|
11439
11491
|
} else if (variant !== "italic") {
|
|
11440
11492
|
text.text = variantChar(text.text, variant);
|
|
11441
11493
|
}
|
|
11442
|
-
let node = new
|
|
11494
|
+
let node = new MathNode("mi", [text]);
|
|
11443
11495
|
// TODO: Handle U+1D49C - U+1D4CF per https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
11444
11496
|
if (variant === "normal") {
|
|
11445
11497
|
node.setAttribute("mathvariant", "normal");
|
|
11446
11498
|
if (text.text.length === 1) {
|
|
11447
11499
|
// A Firefox bug will apply spacing here, but there should be none. Fix it.
|
|
11448
|
-
node = new
|
|
11500
|
+
node = new MathNode("mpadded", [node]);
|
|
11449
11501
|
node.setAttribute("lspace", "0");
|
|
11450
11502
|
}
|
|
11451
11503
|
}
|
|
@@ -11476,15 +11528,15 @@ defineFunctionBuilders({
|
|
|
11476
11528
|
if (variant !== "normal") {
|
|
11477
11529
|
text.text = text.text.split("").map(c => variantChar(c, variant)).join("");
|
|
11478
11530
|
}
|
|
11479
|
-
node = new
|
|
11531
|
+
node = new MathNode(tag, [text]);
|
|
11480
11532
|
}
|
|
11481
11533
|
} else if (group.mode === "text") {
|
|
11482
11534
|
if (variant !== "normal") {
|
|
11483
11535
|
text.text = variantChar(text.text, variant);
|
|
11484
11536
|
}
|
|
11485
|
-
node = new
|
|
11537
|
+
node = new MathNode("mtext", [text]);
|
|
11486
11538
|
} else if (primes.has(group.text)) {
|
|
11487
|
-
node = new
|
|
11539
|
+
node = new MathNode("mo", [text]);
|
|
11488
11540
|
// TODO: If/when Chromium uses ssty variant for prime, remove the next line.
|
|
11489
11541
|
node.classes.push("tml-prime");
|
|
11490
11542
|
} else {
|
|
@@ -11492,7 +11544,7 @@ defineFunctionBuilders({
|
|
|
11492
11544
|
if (variant !== "italic") {
|
|
11493
11545
|
text.text = variantChar(text.text, variant);
|
|
11494
11546
|
}
|
|
11495
|
-
node = new
|
|
11547
|
+
node = new MathNode("mi", [text]);
|
|
11496
11548
|
if (text.text === origText && latinRegEx.test(origText)) {
|
|
11497
11549
|
node.setAttribute("mathvariant", "italic");
|
|
11498
11550
|
}
|
|
@@ -11535,11 +11587,11 @@ defineFunctionBuilders({
|
|
|
11535
11587
|
// Firefox does not render a space in a <mtext> </mtext>. So write a no-break space.
|
|
11536
11588
|
// TODO: If Firefox fixes that bug, uncomment the next line and write ch into the node.
|
|
11537
11589
|
//const ch = (regularSpace[group.text].className === "nobreak") ? "\u00a0" : " "
|
|
11538
|
-
node = new
|
|
11590
|
+
node = new MathNode("mtext", [new TextNode("\u00a0")]);
|
|
11539
11591
|
} else if (Object.prototype.hasOwnProperty.call(cssSpace, group.text)) {
|
|
11540
11592
|
// MathML 3.0 calls for nobreak to occur in an <mo>, not an <mtext>
|
|
11541
11593
|
// Ref: https://www.w3.org/Math/draft-spec/mathml.html#chapter3_presm.lbattrs
|
|
11542
|
-
node = new
|
|
11594
|
+
node = new MathNode("mo");
|
|
11543
11595
|
if (group.text === "\\nobreak") {
|
|
11544
11596
|
node.setAttribute("linebreak", "nobreak");
|
|
11545
11597
|
}
|
|
@@ -11654,10 +11706,10 @@ defineFunction({
|
|
|
11654
11706
|
},
|
|
11655
11707
|
mathmlBuilder(group, style) {
|
|
11656
11708
|
// Use a math table to create vertically centered content.
|
|
11657
|
-
const mtd = new
|
|
11709
|
+
const mtd = new MathNode("mtd", [buildGroup$1(group.body, style)]);
|
|
11658
11710
|
mtd.style.padding = "0";
|
|
11659
|
-
const mtr = new
|
|
11660
|
-
return new
|
|
11711
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
11712
|
+
return new MathNode("mtable", [mtr])
|
|
11661
11713
|
}
|
|
11662
11714
|
});
|
|
11663
11715
|
|
|
@@ -11676,8 +11728,8 @@ defineFunction({
|
|
|
11676
11728
|
throw new ParseError("\\verb ended by end of line instead of matching delimiter");
|
|
11677
11729
|
},
|
|
11678
11730
|
mathmlBuilder(group, style) {
|
|
11679
|
-
const text = new
|
|
11680
|
-
const node = new
|
|
11731
|
+
const text = new TextNode(makeVerb(group));
|
|
11732
|
+
const node = new MathNode("mtext", [text]);
|
|
11681
11733
|
node.setAttribute("mathvariant", "monospace");
|
|
11682
11734
|
return node;
|
|
11683
11735
|
}
|
|
@@ -14009,7 +14061,7 @@ class Style {
|
|
|
14009
14061
|
* https://mit-license.org/
|
|
14010
14062
|
*/
|
|
14011
14063
|
|
|
14012
|
-
const version = "0.
|
|
14064
|
+
const version = "0.12.02";
|
|
14013
14065
|
|
|
14014
14066
|
function postProcess(block) {
|
|
14015
14067
|
const labelMap = {};
|