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.js
CHANGED
|
@@ -182,15 +182,8 @@ var temml = (function () {
|
|
|
182
182
|
return +n.toFixed(4);
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
escape,
|
|
188
|
-
hyphenate,
|
|
189
|
-
getBaseElem,
|
|
190
|
-
isCharacterBox,
|
|
191
|
-
protocolFromUrl,
|
|
192
|
-
round
|
|
193
|
-
};
|
|
185
|
+
// Identify short letters. Used for accents and \cancelto.
|
|
186
|
+
const smalls = "acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳";
|
|
194
187
|
|
|
195
188
|
/**
|
|
196
189
|
* This is a module for storing settings passed into Temml. It correctly handles
|
|
@@ -205,24 +198,24 @@ var temml = (function () {
|
|
|
205
198
|
constructor(options) {
|
|
206
199
|
// allow null options
|
|
207
200
|
options = options || {};
|
|
208
|
-
this.displayMode =
|
|
209
|
-
this.annotate =
|
|
210
|
-
this.leqno =
|
|
211
|
-
this.throwOnError =
|
|
212
|
-
this.errorColor =
|
|
201
|
+
this.displayMode = deflt(options.displayMode, false); // boolean
|
|
202
|
+
this.annotate = deflt(options.annotate, false); // boolean
|
|
203
|
+
this.leqno = deflt(options.leqno, false); // boolean
|
|
204
|
+
this.throwOnError = deflt(options.throwOnError, false); // boolean
|
|
205
|
+
this.errorColor = deflt(options.errorColor, "#b22222"); // string
|
|
213
206
|
this.macros = options.macros || {};
|
|
214
|
-
this.wrap =
|
|
215
|
-
this.xml =
|
|
216
|
-
this.colorIsTextColor =
|
|
217
|
-
this.strict =
|
|
218
|
-
this.trust =
|
|
207
|
+
this.wrap = deflt(options.wrap, "none"); // "none" | "tex" | "="
|
|
208
|
+
this.xml = deflt(options.xml, false); // boolean
|
|
209
|
+
this.colorIsTextColor = deflt(options.colorIsTextColor, false); // boolean
|
|
210
|
+
this.strict = deflt(options.strict, false); // boolean
|
|
211
|
+
this.trust = deflt(options.trust, false); // trust context. See html.js.
|
|
219
212
|
this.maxSize = (options.maxSize === undefined
|
|
220
213
|
? [Infinity, Infinity]
|
|
221
214
|
: Array.isArray(options.maxSize)
|
|
222
215
|
? options.maxSize
|
|
223
216
|
: [Infinity, Infinity]
|
|
224
217
|
);
|
|
225
|
-
this.maxExpand = Math.max(0,
|
|
218
|
+
this.maxExpand = Math.max(0, deflt(options.maxExpand, 1000)); // number
|
|
226
219
|
}
|
|
227
220
|
|
|
228
221
|
/**
|
|
@@ -235,7 +228,7 @@ var temml = (function () {
|
|
|
235
228
|
*/
|
|
236
229
|
isTrusted(context) {
|
|
237
230
|
if (context.url && !context.protocol) {
|
|
238
|
-
const protocol =
|
|
231
|
+
const protocol = protocolFromUrl(context.url);
|
|
239
232
|
if (protocol == null) {
|
|
240
233
|
return false
|
|
241
234
|
}
|
|
@@ -431,7 +424,7 @@ var temml = (function () {
|
|
|
431
424
|
|
|
432
425
|
// Add the class
|
|
433
426
|
if (this.classes.length) {
|
|
434
|
-
markup += ` class="${
|
|
427
|
+
markup += ` class="${escape(createClass(this.classes))}"`;
|
|
435
428
|
}
|
|
436
429
|
|
|
437
430
|
let styles = "";
|
|
@@ -439,7 +432,7 @@ var temml = (function () {
|
|
|
439
432
|
// Add the styles, after hyphenation
|
|
440
433
|
for (const style in this.style) {
|
|
441
434
|
if (Object.prototype.hasOwnProperty.call(this.style, style )) {
|
|
442
|
-
styles += `${
|
|
435
|
+
styles += `${hyphenate(style)}:${this.style[style]};`;
|
|
443
436
|
}
|
|
444
437
|
}
|
|
445
438
|
|
|
@@ -450,7 +443,7 @@ var temml = (function () {
|
|
|
450
443
|
// Add the attributes
|
|
451
444
|
for (const attr in this.attributes) {
|
|
452
445
|
if (Object.prototype.hasOwnProperty.call(this.attributes, attr )) {
|
|
453
|
-
markup += ` ${attr}="${
|
|
446
|
+
markup += ` ${attr}="${escape(this.attributes[attr])}"`;
|
|
454
447
|
}
|
|
455
448
|
}
|
|
456
449
|
|
|
@@ -498,7 +491,7 @@ var temml = (function () {
|
|
|
498
491
|
return document.createTextNode(this.text);
|
|
499
492
|
}
|
|
500
493
|
toMarkup() {
|
|
501
|
-
return
|
|
494
|
+
return escape(this.text);
|
|
502
495
|
}
|
|
503
496
|
};
|
|
504
497
|
|
|
@@ -523,9 +516,9 @@ var temml = (function () {
|
|
|
523
516
|
}
|
|
524
517
|
|
|
525
518
|
toMarkup() {
|
|
526
|
-
let markup = `<a href='${
|
|
519
|
+
let markup = `<a href='${escape(this.href)}'`;
|
|
527
520
|
if (this.classes.length > 0) {
|
|
528
|
-
markup += ` class="${
|
|
521
|
+
markup += ` class="${escape(createClass(this.classes))}"`;
|
|
529
522
|
}
|
|
530
523
|
markup += ">";
|
|
531
524
|
for (let i = 0; i < this.children.length; i++) {
|
|
@@ -574,11 +567,11 @@ var temml = (function () {
|
|
|
574
567
|
let styles = "";
|
|
575
568
|
for (const style in this.style) {
|
|
576
569
|
if (Object.prototype.hasOwnProperty.call(this.style, style )) {
|
|
577
|
-
styles += `${
|
|
570
|
+
styles += `${hyphenate(style)}:${this.style[style]};`;
|
|
578
571
|
}
|
|
579
572
|
}
|
|
580
573
|
if (styles) {
|
|
581
|
-
markup += ` style="${
|
|
574
|
+
markup += ` style="${escape(styles)}"`;
|
|
582
575
|
}
|
|
583
576
|
|
|
584
577
|
markup += ">";
|
|
@@ -672,13 +665,13 @@ var temml = (function () {
|
|
|
672
665
|
for (const attr in this.attributes) {
|
|
673
666
|
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
674
667
|
markup += " " + attr + '="';
|
|
675
|
-
markup +=
|
|
668
|
+
markup += escape(this.attributes[attr]);
|
|
676
669
|
markup += '"';
|
|
677
670
|
}
|
|
678
671
|
}
|
|
679
672
|
|
|
680
673
|
if (this.classes.length > 0) {
|
|
681
|
-
markup += ` class="${
|
|
674
|
+
markup += ` class="${escape(createClass(this.classes))}"`;
|
|
682
675
|
}
|
|
683
676
|
|
|
684
677
|
let styles = "";
|
|
@@ -686,7 +679,7 @@ var temml = (function () {
|
|
|
686
679
|
// Add the styles, after hyphenation
|
|
687
680
|
for (const style in this.style) {
|
|
688
681
|
if (Object.prototype.hasOwnProperty.call(this.style, style )) {
|
|
689
|
-
styles += `${
|
|
682
|
+
styles += `${hyphenate(style)}:${this.style[style]};`;
|
|
690
683
|
}
|
|
691
684
|
}
|
|
692
685
|
|
|
@@ -733,7 +726,7 @@ var temml = (function () {
|
|
|
733
726
|
* (representing the text itself).
|
|
734
727
|
*/
|
|
735
728
|
toMarkup() {
|
|
736
|
-
return
|
|
729
|
+
return escape(this.toText());
|
|
737
730
|
}
|
|
738
731
|
|
|
739
732
|
/**
|
|
@@ -758,12 +751,6 @@ var temml = (function () {
|
|
|
758
751
|
return node
|
|
759
752
|
};
|
|
760
753
|
|
|
761
|
-
var mathMLTree = {
|
|
762
|
-
MathNode,
|
|
763
|
-
TextNode,
|
|
764
|
-
newDocumentFragment
|
|
765
|
-
};
|
|
766
|
-
|
|
767
754
|
/**
|
|
768
755
|
* This file provides support for building horizontal stretchy elements.
|
|
769
756
|
*/
|
|
@@ -813,6 +800,8 @@ var temml = (function () {
|
|
|
813
800
|
xrightarrow: "\u2192",
|
|
814
801
|
underbrace: "\u23df",
|
|
815
802
|
overbrace: "\u23de",
|
|
803
|
+
overbracket: "\u23b4",
|
|
804
|
+
underbracket: "\u23b5",
|
|
816
805
|
overgroup: "\u23e0",
|
|
817
806
|
overparen: "⏜",
|
|
818
807
|
undergroup: "\u23e1",
|
|
@@ -855,8 +844,8 @@ var temml = (function () {
|
|
|
855
844
|
};
|
|
856
845
|
|
|
857
846
|
const mathMLnode = function(label) {
|
|
858
|
-
const child = new
|
|
859
|
-
const node = new
|
|
847
|
+
const child = new TextNode(stretchyCodePoint[label.slice(1)]);
|
|
848
|
+
const node = new MathNode("mo", [child]);
|
|
860
849
|
node.setAttribute("stretchy", "true");
|
|
861
850
|
return node
|
|
862
851
|
};
|
|
@@ -879,11 +868,6 @@ var temml = (function () {
|
|
|
879
868
|
return mo
|
|
880
869
|
};
|
|
881
870
|
|
|
882
|
-
var stretchy = {
|
|
883
|
-
mathMLnode,
|
|
884
|
-
accentNode
|
|
885
|
-
};
|
|
886
|
-
|
|
887
871
|
/**
|
|
888
872
|
* This file holds a list of all no-argument functions and single-character
|
|
889
873
|
* symbols (like 'a' or ';').
|
|
@@ -2037,13 +2021,13 @@ var temml = (function () {
|
|
|
2037
2021
|
node.attributes.linebreak === "newline") {
|
|
2038
2022
|
// A hard line break. Create a <mtr> for the current block.
|
|
2039
2023
|
if (block.length > 0) {
|
|
2040
|
-
mrows.push(new
|
|
2024
|
+
mrows.push(new MathNode("mrow", block));
|
|
2041
2025
|
}
|
|
2042
2026
|
mrows.push(node);
|
|
2043
2027
|
block = [];
|
|
2044
|
-
const mtd = new
|
|
2028
|
+
const mtd = new MathNode("mtd", mrows);
|
|
2045
2029
|
mtd.style.textAlign = "left";
|
|
2046
|
-
mtrs.push(new
|
|
2030
|
+
mtrs.push(new MathNode("mtr", [mtd]));
|
|
2047
2031
|
mrows = [];
|
|
2048
2032
|
i += 1;
|
|
2049
2033
|
continue
|
|
@@ -2061,7 +2045,7 @@ var temml = (function () {
|
|
|
2061
2045
|
if (numTopLevelEquals > 1) {
|
|
2062
2046
|
block.pop();
|
|
2063
2047
|
// Start a new block. (Insert a soft linebreak.)
|
|
2064
|
-
const element = new
|
|
2048
|
+
const element = new MathNode("mrow", block);
|
|
2065
2049
|
mrows.push(element);
|
|
2066
2050
|
block = [node];
|
|
2067
2051
|
}
|
|
@@ -2102,7 +2086,7 @@ var temml = (function () {
|
|
|
2102
2086
|
}
|
|
2103
2087
|
if (glueIsFreeOfNobreak) {
|
|
2104
2088
|
// Start a new block. (Insert a soft linebreak.)
|
|
2105
|
-
const element = new
|
|
2089
|
+
const element = new MathNode("mrow", block);
|
|
2106
2090
|
mrows.push(element);
|
|
2107
2091
|
block = [];
|
|
2108
2092
|
}
|
|
@@ -2111,22 +2095,22 @@ var temml = (function () {
|
|
|
2111
2095
|
i += 1;
|
|
2112
2096
|
}
|
|
2113
2097
|
if (block.length > 0) {
|
|
2114
|
-
const element = new
|
|
2098
|
+
const element = new MathNode("mrow", block);
|
|
2115
2099
|
mrows.push(element);
|
|
2116
2100
|
}
|
|
2117
2101
|
if (mtrs.length > 0) {
|
|
2118
|
-
const mtd = new
|
|
2102
|
+
const mtd = new MathNode("mtd", mrows);
|
|
2119
2103
|
mtd.style.textAlign = "left";
|
|
2120
|
-
const mtr = new
|
|
2104
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
2121
2105
|
mtrs.push(mtr);
|
|
2122
|
-
const mtable = new
|
|
2106
|
+
const mtable = new MathNode("mtable", mtrs);
|
|
2123
2107
|
if (!isDisplayMode) {
|
|
2124
2108
|
mtable.setAttribute("columnalign", "left");
|
|
2125
2109
|
mtable.setAttribute("rowspacing", "0em");
|
|
2126
2110
|
}
|
|
2127
2111
|
return mtable
|
|
2128
2112
|
}
|
|
2129
|
-
return
|
|
2113
|
+
return newDocumentFragment(mrows);
|
|
2130
2114
|
}
|
|
2131
2115
|
|
|
2132
2116
|
/**
|
|
@@ -2155,15 +2139,15 @@ var temml = (function () {
|
|
|
2155
2139
|
text = symbols[mode][text].replace;
|
|
2156
2140
|
}
|
|
2157
2141
|
|
|
2158
|
-
return new
|
|
2142
|
+
return new TextNode(text);
|
|
2159
2143
|
};
|
|
2160
2144
|
|
|
2161
2145
|
const copyChar = (newRow, child) => {
|
|
2162
2146
|
if (newRow.children.length === 0 ||
|
|
2163
2147
|
newRow.children[newRow.children.length - 1].type !== "mtext") {
|
|
2164
|
-
const mtext = new
|
|
2148
|
+
const mtext = new MathNode(
|
|
2165
2149
|
"mtext",
|
|
2166
|
-
[new
|
|
2150
|
+
[new TextNode(child.children[0].text)]
|
|
2167
2151
|
);
|
|
2168
2152
|
newRow.children.push(mtext);
|
|
2169
2153
|
} else {
|
|
@@ -2175,7 +2159,7 @@ var temml = (function () {
|
|
|
2175
2159
|
// If possible, consolidate adjacent <mtext> elements into a single element.
|
|
2176
2160
|
if (mrow.type !== "mrow" && mrow.type !== "mstyle") { return mrow }
|
|
2177
2161
|
if (mrow.children.length === 0) { return mrow } // empty group, e.g., \text{}
|
|
2178
|
-
const newRow = new
|
|
2162
|
+
const newRow = new MathNode("mrow");
|
|
2179
2163
|
for (let i = 0; i < mrow.children.length; i++) {
|
|
2180
2164
|
const child = mrow.children[i];
|
|
2181
2165
|
if (child.type === "mtext" && Object.keys(child.attributes).length === 0) {
|
|
@@ -2245,7 +2229,7 @@ var temml = (function () {
|
|
|
2245
2229
|
body[end].attributes.rspace = "0em";
|
|
2246
2230
|
}
|
|
2247
2231
|
}
|
|
2248
|
-
return new
|
|
2232
|
+
return new MathNode("mrow", body);
|
|
2249
2233
|
};
|
|
2250
2234
|
|
|
2251
2235
|
/**
|
|
@@ -2370,7 +2354,7 @@ var temml = (function () {
|
|
|
2370
2354
|
*/
|
|
2371
2355
|
const buildGroup$1 = function(group, style) {
|
|
2372
2356
|
if (!group) {
|
|
2373
|
-
return new
|
|
2357
|
+
return new MathNode("mrow");
|
|
2374
2358
|
}
|
|
2375
2359
|
|
|
2376
2360
|
if (_mathmlGroupBuilders[group.type]) {
|
|
@@ -2383,7 +2367,7 @@ var temml = (function () {
|
|
|
2383
2367
|
};
|
|
2384
2368
|
|
|
2385
2369
|
const glue$1 = _ => {
|
|
2386
|
-
return new
|
|
2370
|
+
return new MathNode("mtd", [], [], { padding: "0", width: "50%" })
|
|
2387
2371
|
};
|
|
2388
2372
|
|
|
2389
2373
|
const labelContainers = ["mrow", "mtd", "mtable", "mtr"];
|
|
@@ -2410,12 +2394,12 @@ var temml = (function () {
|
|
|
2410
2394
|
tag.classes.push("tml-tag"); // to be available for \ref
|
|
2411
2395
|
|
|
2412
2396
|
const label = getLabel(expression); // from a \label{} function.
|
|
2413
|
-
expression = new
|
|
2397
|
+
expression = new MathNode("mtd", [expression]);
|
|
2414
2398
|
const rowArray = [glue$1(), expression, glue$1()];
|
|
2415
2399
|
rowArray[leqno ? 0 : 2].children.push(tag);
|
|
2416
|
-
const mtr = new
|
|
2400
|
+
const mtr = new MathNode("mtr", rowArray, ["tml-tageqn"]);
|
|
2417
2401
|
if (label) { mtr.setAttribute("id", label); }
|
|
2418
|
-
const table = new
|
|
2402
|
+
const table = new MathNode("mtable", [mtr]);
|
|
2419
2403
|
table.style.width = "100%";
|
|
2420
2404
|
table.setAttribute("displaystyle", "true");
|
|
2421
2405
|
return table
|
|
@@ -2452,13 +2436,13 @@ var temml = (function () {
|
|
|
2452
2436
|
|
|
2453
2437
|
if (settings.annotate) {
|
|
2454
2438
|
// Build a TeX annotation of the source
|
|
2455
|
-
const annotation = new
|
|
2456
|
-
"annotation", [new
|
|
2439
|
+
const annotation = new MathNode(
|
|
2440
|
+
"annotation", [new TextNode(texExpression)]);
|
|
2457
2441
|
annotation.setAttribute("encoding", "application/x-tex");
|
|
2458
|
-
wrapper = new
|
|
2442
|
+
wrapper = new MathNode("semantics", [wrapper, annotation]);
|
|
2459
2443
|
}
|
|
2460
2444
|
|
|
2461
|
-
const math = new
|
|
2445
|
+
const math = new MathNode("math", [wrapper]);
|
|
2462
2446
|
|
|
2463
2447
|
if (settings.xml) {
|
|
2464
2448
|
math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
|
|
@@ -2473,23 +2457,20 @@ var temml = (function () {
|
|
|
2473
2457
|
return math;
|
|
2474
2458
|
}
|
|
2475
2459
|
|
|
2476
|
-
// Identify letters to which we'll attach a combining accent character
|
|
2477
|
-
const smalls = "acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳";
|
|
2478
|
-
|
|
2479
2460
|
// From the KaTeX font metrics, identify letters whose accents need a italic correction.
|
|
2480
2461
|
const smallNudge = "DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ";
|
|
2481
2462
|
const mediumNudge = "BCEGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ";
|
|
2482
2463
|
const largeNudge = "AFJdfΔΛ";
|
|
2483
2464
|
|
|
2484
2465
|
const mathmlBuilder$a = (group, style) => {
|
|
2485
|
-
const accentNode = group.isStretchy
|
|
2486
|
-
?
|
|
2487
|
-
: new
|
|
2466
|
+
const accentNode$1 = group.isStretchy
|
|
2467
|
+
? accentNode(group)
|
|
2468
|
+
: new MathNode("mo", [makeText(group.label, group.mode)]);
|
|
2488
2469
|
if (!group.isStretchy) {
|
|
2489
|
-
accentNode.setAttribute("stretchy", "false"); // Keep Firefox from stretching \check
|
|
2470
|
+
accentNode$1.setAttribute("stretchy", "false"); // Keep Firefox from stretching \check
|
|
2490
2471
|
}
|
|
2491
2472
|
if (group.label !== "\\vec") {
|
|
2492
|
-
accentNode.style.mathDepth = "0"; // not scriptstyle
|
|
2473
|
+
accentNode$1.style.mathDepth = "0"; // not scriptstyle
|
|
2493
2474
|
// Don't use attribute accent="true" because MathML Core eliminates a needed space.
|
|
2494
2475
|
}
|
|
2495
2476
|
const tag = group.label === "\\c" ? "munder" : "mover";
|
|
@@ -2500,28 +2481,28 @@ var temml = (function () {
|
|
|
2500
2481
|
const isVec = group.label === "\\vec";
|
|
2501
2482
|
const vecPostfix = isVec === "\\vec" ? "-vec" : "";
|
|
2502
2483
|
if (isVec) {
|
|
2503
|
-
accentNode.classes.push("tml-vec"); // Firefox sizing of \vec arrow
|
|
2484
|
+
accentNode$1.classes.push("tml-vec"); // Firefox sizing of \vec arrow
|
|
2504
2485
|
}
|
|
2505
2486
|
const wbkPostfix = isVec ? "-vec" : needsWbkVertShift ? "-acc" : "";
|
|
2506
2487
|
if (smallNudge.indexOf(text) > -1) {
|
|
2507
|
-
accentNode.classes.push(`chr-sml${vecPostfix}`);
|
|
2508
|
-
accentNode.classes.push(`wbk-sml${wbkPostfix}`);
|
|
2488
|
+
accentNode$1.classes.push(`chr-sml${vecPostfix}`);
|
|
2489
|
+
accentNode$1.classes.push(`wbk-sml${wbkPostfix}`);
|
|
2509
2490
|
} else if (mediumNudge.indexOf(text) > -1) {
|
|
2510
|
-
accentNode.classes.push(`chr-med${vecPostfix}`);
|
|
2511
|
-
accentNode.classes.push(`wbk-med${wbkPostfix}`);
|
|
2491
|
+
accentNode$1.classes.push(`chr-med${vecPostfix}`);
|
|
2492
|
+
accentNode$1.classes.push(`wbk-med${wbkPostfix}`);
|
|
2512
2493
|
} else if (largeNudge.indexOf(text) > -1) {
|
|
2513
|
-
accentNode.classes.push(`chr-lrg${vecPostfix}`);
|
|
2514
|
-
accentNode.classes.push(`wbk-lrg${wbkPostfix}`);
|
|
2494
|
+
accentNode$1.classes.push(`chr-lrg${vecPostfix}`);
|
|
2495
|
+
accentNode$1.classes.push(`wbk-lrg${wbkPostfix}`);
|
|
2515
2496
|
} else if (isVec) {
|
|
2516
|
-
accentNode.classes.push(`wbk-vec`);
|
|
2497
|
+
accentNode$1.classes.push(`wbk-vec`);
|
|
2517
2498
|
} else if (needsWbkVertShift) {
|
|
2518
|
-
accentNode.classes.push(`wbk-acc`);
|
|
2499
|
+
accentNode$1.classes.push(`wbk-acc`);
|
|
2519
2500
|
}
|
|
2520
2501
|
} else if (needsWbkVertShift) {
|
|
2521
2502
|
// text-mode accents
|
|
2522
|
-
accentNode.classes.push("wbk-acc");
|
|
2503
|
+
accentNode$1.classes.push("wbk-acc");
|
|
2523
2504
|
}
|
|
2524
|
-
const node = new
|
|
2505
|
+
const node = new MathNode(tag, [buildGroup$1(group.base, style), accentNode$1]);
|
|
2525
2506
|
return node;
|
|
2526
2507
|
};
|
|
2527
2508
|
|
|
@@ -2688,11 +2669,11 @@ var temml = (function () {
|
|
|
2688
2669
|
};
|
|
2689
2670
|
},
|
|
2690
2671
|
mathmlBuilder: (group, style) => {
|
|
2691
|
-
const accentNode =
|
|
2692
|
-
accentNode.style["math-depth"] = 0;
|
|
2693
|
-
const node = new
|
|
2672
|
+
const accentNode$1 = accentNode(group);
|
|
2673
|
+
accentNode$1.style["math-depth"] = 0;
|
|
2674
|
+
const node = new MathNode("munder", [
|
|
2694
2675
|
buildGroup$1(group.base, style),
|
|
2695
|
-
accentNode
|
|
2676
|
+
accentNode$1
|
|
2696
2677
|
]);
|
|
2697
2678
|
return node;
|
|
2698
2679
|
}
|
|
@@ -2781,7 +2762,7 @@ var temml = (function () {
|
|
|
2781
2762
|
// In TeX, em and ex do not change size in \scriptstyle.
|
|
2782
2763
|
if (unit === "ex") { number *= 0.431; }
|
|
2783
2764
|
number = Math.min(number / emScale(style.level), style.maxSize[0]);
|
|
2784
|
-
return { number:
|
|
2765
|
+
return { number: round(number), unit: "em" };
|
|
2785
2766
|
}
|
|
2786
2767
|
case "bp": {
|
|
2787
2768
|
if (number > style.maxSize[1]) { number = style.maxSize[1]; }
|
|
@@ -2795,11 +2776,11 @@ var temml = (function () {
|
|
|
2795
2776
|
case "nc":
|
|
2796
2777
|
case "sp": {
|
|
2797
2778
|
number = Math.min(number * ptPerUnit[unit], style.maxSize[1]);
|
|
2798
|
-
return { number:
|
|
2779
|
+
return { number: round(number), unit: "pt" }
|
|
2799
2780
|
}
|
|
2800
2781
|
case "mu": {
|
|
2801
2782
|
number = Math.min(number / 18, style.maxSize[0]);
|
|
2802
|
-
return { number:
|
|
2783
|
+
return { number: round(number), unit: "em" }
|
|
2803
2784
|
}
|
|
2804
2785
|
default:
|
|
2805
2786
|
throw new ParseError("Invalid unit: '" + unit + "'")
|
|
@@ -2809,7 +2790,7 @@ var temml = (function () {
|
|
|
2809
2790
|
// Helper functions
|
|
2810
2791
|
|
|
2811
2792
|
const padding = width => {
|
|
2812
|
-
const node = new
|
|
2793
|
+
const node = new MathNode("mspace");
|
|
2813
2794
|
node.setAttribute("width", width + "em");
|
|
2814
2795
|
return node
|
|
2815
2796
|
};
|
|
@@ -2821,18 +2802,18 @@ var temml = (function () {
|
|
|
2821
2802
|
if (rspace > 0) { row.push(padding(rspace)); }
|
|
2822
2803
|
if (mustSmash) {
|
|
2823
2804
|
// Used for the bottom arrow in a {CD} environment
|
|
2824
|
-
const mpadded = new
|
|
2805
|
+
const mpadded = new MathNode("mpadded", row);
|
|
2825
2806
|
mpadded.setAttribute("height", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
2826
2807
|
return mpadded
|
|
2827
2808
|
} else {
|
|
2828
|
-
return new
|
|
2809
|
+
return new MathNode("mrow", row)
|
|
2829
2810
|
}
|
|
2830
2811
|
};
|
|
2831
2812
|
|
|
2832
2813
|
const labelSize = (size, scriptLevel) => Number(size) / emScale(scriptLevel);
|
|
2833
2814
|
|
|
2834
2815
|
const munderoverNode = (fName, body, below, style) => {
|
|
2835
|
-
const arrowNode =
|
|
2816
|
+
const arrowNode = mathMLnode(fName);
|
|
2836
2817
|
// Is this the short part of a mhchem equilibrium arrow?
|
|
2837
2818
|
const isEq = fName.slice(1, 3) === "eq";
|
|
2838
2819
|
const minWidth = fName.charAt(1) === "x"
|
|
@@ -2871,25 +2852,25 @@ var temml = (function () {
|
|
|
2871
2852
|
// Since Firefox does not support minsize, stack a invisible node
|
|
2872
2853
|
// on top of the label. Its width will serve as a min-width.
|
|
2873
2854
|
// TODO: Refactor this after Firefox supports minsize.
|
|
2874
|
-
upperNode = new
|
|
2855
|
+
upperNode = new MathNode("mover", [label, dummyNode]);
|
|
2875
2856
|
}
|
|
2876
2857
|
const gotLower = (below && below.body &&
|
|
2877
2858
|
(below.body.body || below.body.length > 0));
|
|
2878
2859
|
if (gotLower) {
|
|
2879
2860
|
let label = buildGroup$1(below, labelStyle);
|
|
2880
2861
|
label = paddedNode(label, space, space);
|
|
2881
|
-
lowerNode = new
|
|
2862
|
+
lowerNode = new MathNode("munder", [label, dummyNode]);
|
|
2882
2863
|
}
|
|
2883
2864
|
|
|
2884
2865
|
let node;
|
|
2885
2866
|
if (!gotUpper && !gotLower) {
|
|
2886
|
-
node = new
|
|
2867
|
+
node = new MathNode("mover", [arrowNode, emptyLabel]);
|
|
2887
2868
|
} else if (gotUpper && gotLower) {
|
|
2888
|
-
node = new
|
|
2869
|
+
node = new MathNode("munderover", [arrowNode, lowerNode, upperNode]);
|
|
2889
2870
|
} else if (gotUpper) {
|
|
2890
|
-
node = new
|
|
2871
|
+
node = new MathNode("mover", [arrowNode, upperNode]);
|
|
2891
2872
|
} else {
|
|
2892
|
-
node = new
|
|
2873
|
+
node = new MathNode("munder", [arrowNode, lowerNode]);
|
|
2893
2874
|
}
|
|
2894
2875
|
if (minWidth === "3.0") { node.style.height = "1em"; } // CD environment
|
|
2895
2876
|
node.setAttribute("accent", "false"); // Necessary for MS Word
|
|
@@ -2952,7 +2933,7 @@ var temml = (function () {
|
|
|
2952
2933
|
const row = [node];
|
|
2953
2934
|
row.unshift(padding(0.2778));
|
|
2954
2935
|
row.push(padding(0.2778));
|
|
2955
|
-
return new
|
|
2936
|
+
return new MathNode("mrow", row)
|
|
2956
2937
|
}
|
|
2957
2938
|
});
|
|
2958
2939
|
|
|
@@ -3005,21 +2986,21 @@ var temml = (function () {
|
|
|
3005
2986
|
const botArrow = munderoverNode(botLabel, group.lowerArrowBody, group.below, style);
|
|
3006
2987
|
let wrapper;
|
|
3007
2988
|
|
|
3008
|
-
const raiseNode = new
|
|
2989
|
+
const raiseNode = new MathNode("mpadded", [topArrow]);
|
|
3009
2990
|
raiseNode.setAttribute("voffset", "0.3em");
|
|
3010
2991
|
raiseNode.setAttribute("height", "+0.3em");
|
|
3011
2992
|
raiseNode.setAttribute("depth", "-0.3em");
|
|
3012
2993
|
// One of the arrows is given ~zero width. so the other has the same horzontal alignment.
|
|
3013
2994
|
if (group.name === "\\equilibriumLeft") {
|
|
3014
|
-
const botNode = new
|
|
2995
|
+
const botNode = new MathNode("mpadded", [botArrow]);
|
|
3015
2996
|
botNode.setAttribute("width", "0.5em");
|
|
3016
|
-
wrapper = new
|
|
2997
|
+
wrapper = new MathNode(
|
|
3017
2998
|
"mpadded",
|
|
3018
2999
|
[padding(0.2778), botNode, raiseNode, padding(0.2778)]
|
|
3019
3000
|
);
|
|
3020
3001
|
} else {
|
|
3021
3002
|
raiseNode.setAttribute("width", (group.name === "\\equilibriumRight" ? "0.5em" : "0"));
|
|
3022
|
-
wrapper = new
|
|
3003
|
+
wrapper = new MathNode(
|
|
3023
3004
|
"mpadded",
|
|
3024
3005
|
[padding(0.2778), raiseNode, botArrow, padding(0.2778)]
|
|
3025
3006
|
);
|
|
@@ -3311,18 +3292,18 @@ var temml = (function () {
|
|
|
3311
3292
|
},
|
|
3312
3293
|
mathmlBuilder(group, style) {
|
|
3313
3294
|
if (group.label.body.length === 0) {
|
|
3314
|
-
return new
|
|
3295
|
+
return new MathNode("mrow", style) // empty label
|
|
3315
3296
|
}
|
|
3316
3297
|
// Abuse an <mtable> to create vertically centered content.
|
|
3317
3298
|
const mrow = buildGroup$1(group.label, style);
|
|
3318
3299
|
if (group.side === "left") {
|
|
3319
3300
|
mrow.classes.push("tml-shift-left");
|
|
3320
3301
|
}
|
|
3321
|
-
const mtd = new
|
|
3302
|
+
const mtd = new MathNode("mtd", [mrow]);
|
|
3322
3303
|
mtd.style.padding = "0";
|
|
3323
|
-
const mtr = new
|
|
3324
|
-
const mtable = new
|
|
3325
|
-
const label = new
|
|
3304
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
3305
|
+
const mtable = new MathNode("mtable", [mtr]);
|
|
3306
|
+
const label = new MathNode("mpadded", [mtable]);
|
|
3326
3307
|
// Set the label width to zero so that the arrow will be centered under the corner cell.
|
|
3327
3308
|
label.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
3328
3309
|
label.setAttribute("displaystyle", "false");
|
|
@@ -3345,7 +3326,7 @@ var temml = (function () {
|
|
|
3345
3326
|
};
|
|
3346
3327
|
},
|
|
3347
3328
|
mathmlBuilder(group, style) {
|
|
3348
|
-
return new
|
|
3329
|
+
return new MathNode("mrow", [buildGroup$1(group.fragment, style)]);
|
|
3349
3330
|
}
|
|
3350
3331
|
});
|
|
3351
3332
|
|
|
@@ -4530,7 +4511,7 @@ var temml = (function () {
|
|
|
4530
4511
|
};
|
|
4531
4512
|
|
|
4532
4513
|
const glue = group => {
|
|
4533
|
-
const glueNode = new
|
|
4514
|
+
const glueNode = new MathNode("mtd", []);
|
|
4534
4515
|
glueNode.style = { padding: "0", width: "50%" };
|
|
4535
4516
|
if (group.envClasses.includes("multline")) {
|
|
4536
4517
|
glueNode.style.width = "7.5%";
|
|
@@ -4542,6 +4523,7 @@ var temml = (function () {
|
|
|
4542
4523
|
const tbl = [];
|
|
4543
4524
|
const numRows = group.body.length;
|
|
4544
4525
|
const hlines = group.hLinesBeforeRow;
|
|
4526
|
+
const tagIsPresent = (group.tags && group.tags.some((tag) => tag));
|
|
4545
4527
|
|
|
4546
4528
|
for (let i = 0; i < numRows; i++) {
|
|
4547
4529
|
const rw = group.body[i];
|
|
@@ -4553,7 +4535,7 @@ var temml = (function () {
|
|
|
4553
4535
|
: StyleLevel.DISPLAY;
|
|
4554
4536
|
|
|
4555
4537
|
for (let j = 0; j < rw.length; j++) {
|
|
4556
|
-
const mtd = new
|
|
4538
|
+
const mtd = new MathNode(
|
|
4557
4539
|
"mtd",
|
|
4558
4540
|
[buildGroup$1(rw[j], style.withLevel(cellLevel))]
|
|
4559
4541
|
);
|
|
@@ -4569,16 +4551,16 @@ var temml = (function () {
|
|
|
4569
4551
|
const numColumns = group.body[0].length;
|
|
4570
4552
|
// Fill out a short row with empty <mtd> elements.
|
|
4571
4553
|
for (let k = 0; k < numColumns - rw.length; k++) {
|
|
4572
|
-
row.push(new
|
|
4554
|
+
row.push(new MathNode("mtd", [], [], style));
|
|
4573
4555
|
}
|
|
4574
|
-
if (
|
|
4556
|
+
if (tagIsPresent) {
|
|
4575
4557
|
const tag = group.tags[i];
|
|
4576
4558
|
let tagElement;
|
|
4577
4559
|
if (tag === true) { // automatic numbering
|
|
4578
|
-
tagElement = new
|
|
4560
|
+
tagElement = new MathNode("mtext", [new Span(["tml-eqn"])]);
|
|
4579
4561
|
} else if (tag === false) {
|
|
4580
4562
|
// \nonumber/\notag or starred environment
|
|
4581
|
-
tagElement = new
|
|
4563
|
+
tagElement = new MathNode("mtext", [], []);
|
|
4582
4564
|
} else { // manual \tag
|
|
4583
4565
|
tagElement = buildExpressionRow(tag[0].body, style.withLevel(cellLevel), true);
|
|
4584
4566
|
tagElement = consolidateText(tagElement);
|
|
@@ -4594,7 +4576,7 @@ var temml = (function () {
|
|
|
4594
4576
|
}
|
|
4595
4577
|
}
|
|
4596
4578
|
}
|
|
4597
|
-
const mtr = new
|
|
4579
|
+
const mtr = new MathNode("mtr", row, []);
|
|
4598
4580
|
const label = group.labels.shift();
|
|
4599
4581
|
if (label && group.tags && group.tags[i]) {
|
|
4600
4582
|
mtr.setAttribute("id", label);
|
|
@@ -4683,7 +4665,7 @@ var temml = (function () {
|
|
|
4683
4665
|
if (j === numCols - 1 && hand === 1) { return "0" }
|
|
4684
4666
|
if (group.envClasses[0] !== "align") { return sidePadding }
|
|
4685
4667
|
if (hand === 1) { return "0" }
|
|
4686
|
-
if (
|
|
4668
|
+
if (tagIsPresent) {
|
|
4687
4669
|
return (j % 2) ? "1" : "0"
|
|
4688
4670
|
} else {
|
|
4689
4671
|
return (j % 2) ? "0" : "1"
|
|
@@ -4719,7 +4701,7 @@ var temml = (function () {
|
|
|
4719
4701
|
// TODO: Remove -webkit- when Chromium no longer needs it.
|
|
4720
4702
|
row.children[j].classes = ["tml-" + (j % 2 ? "left" : "right")];
|
|
4721
4703
|
}
|
|
4722
|
-
if (
|
|
4704
|
+
if (tagIsPresent) {
|
|
4723
4705
|
const k = group.leqno ? 0 : row.children.length - 1;
|
|
4724
4706
|
row.children[k].classes = []; // Default is center.
|
|
4725
4707
|
}
|
|
@@ -4736,7 +4718,7 @@ var temml = (function () {
|
|
|
4736
4718
|
}
|
|
4737
4719
|
}
|
|
4738
4720
|
|
|
4739
|
-
let table = new
|
|
4721
|
+
let table = new MathNode("mtable", tbl);
|
|
4740
4722
|
if (group.envClasses.length > 0) {
|
|
4741
4723
|
// Top & bottom padding
|
|
4742
4724
|
if (group.envClasses.includes("jot")) {
|
|
@@ -4776,7 +4758,7 @@ var temml = (function () {
|
|
|
4776
4758
|
row.children[0].style.borderLeft = sep;
|
|
4777
4759
|
}
|
|
4778
4760
|
}
|
|
4779
|
-
let iCol =
|
|
4761
|
+
let iCol = tagIsPresent ? 0 : -1;
|
|
4780
4762
|
for (let i = iStart; i < iEnd; i++) {
|
|
4781
4763
|
if (cols[i].type === "align") {
|
|
4782
4764
|
const colAlign = alignMap[cols[i].align];
|
|
@@ -4820,7 +4802,7 @@ var temml = (function () {
|
|
|
4820
4802
|
|
|
4821
4803
|
if (group.envClasses.includes("small")) {
|
|
4822
4804
|
// A small array. Wrap in scriptstyle.
|
|
4823
|
-
table = new
|
|
4805
|
+
table = new MathNode("mstyle", [table]);
|
|
4824
4806
|
table.setAttribute("scriptlevel", "1");
|
|
4825
4807
|
}
|
|
4826
4808
|
|
|
@@ -5067,9 +5049,8 @@ var temml = (function () {
|
|
|
5067
5049
|
numArgs: 0
|
|
5068
5050
|
},
|
|
5069
5051
|
handler(context) {
|
|
5070
|
-
const payload = {
|
|
5052
|
+
const payload = { envClasses: ["small"] };
|
|
5071
5053
|
const res = parseArray(context.parser, payload, "script");
|
|
5072
|
-
res.envClasses = ["small"];
|
|
5073
5054
|
return res;
|
|
5074
5055
|
},
|
|
5075
5056
|
mathmlBuilder: mathmlBuilder$9
|
|
@@ -5303,6 +5284,78 @@ var temml = (function () {
|
|
|
5303
5284
|
}
|
|
5304
5285
|
});
|
|
5305
5286
|
|
|
5287
|
+
defineFunction({
|
|
5288
|
+
type: "cancelto",
|
|
5289
|
+
names: ["\\cancelto"],
|
|
5290
|
+
props: {
|
|
5291
|
+
numArgs: 2
|
|
5292
|
+
},
|
|
5293
|
+
handler({ parser }, args) {
|
|
5294
|
+
const to = args[0];
|
|
5295
|
+
const body = args[1];
|
|
5296
|
+
return {
|
|
5297
|
+
type: "cancelto",
|
|
5298
|
+
mode: parser.mode,
|
|
5299
|
+
body,
|
|
5300
|
+
to,
|
|
5301
|
+
isCharacterBox: isCharacterBox(body)
|
|
5302
|
+
};
|
|
5303
|
+
},
|
|
5304
|
+
mathmlBuilder(group, style) {
|
|
5305
|
+
const fromNode = new MathNode(
|
|
5306
|
+
"mrow",
|
|
5307
|
+
[buildGroup$1(group.body, style)],
|
|
5308
|
+
["ff-narrow"] // A zero-width mrow.
|
|
5309
|
+
);
|
|
5310
|
+
// Write the arrow in a node written after the content.
|
|
5311
|
+
// That way, the arrow will be an overlay on the content.
|
|
5312
|
+
const phantom = new MathNode("mphantom", [buildGroup$1(group.body, style)]);
|
|
5313
|
+
const arrow = new MathNode("mrow", [phantom], ["tml-cancelto"]);
|
|
5314
|
+
if (group.isCharacterBox && smalls.indexOf(group.body.body[0].text) > -1) {
|
|
5315
|
+
arrow.style.left = "0.1em";
|
|
5316
|
+
arrow.style.width = "90%";
|
|
5317
|
+
}
|
|
5318
|
+
const node = new MathNode("mrow", [fromNode, arrow], ["menclose"]);
|
|
5319
|
+
if (!group.isCharacterBox || /[f∫∑]/.test(group.body.body[0].text)) {
|
|
5320
|
+
// Add 0.2em space to right of content to make room for the arrowhead.
|
|
5321
|
+
phantom.style.paddingRight = "0.2em";
|
|
5322
|
+
} else {
|
|
5323
|
+
phantom.style.padding = "0.5ex 0.1em 0 0";
|
|
5324
|
+
const strut = new MathNode('mspace', []);
|
|
5325
|
+
strut.setAttribute('height', "0.85em");
|
|
5326
|
+
fromNode.children.push(strut);
|
|
5327
|
+
}
|
|
5328
|
+
|
|
5329
|
+
// Create the "to" value above and to the right of the arrow.
|
|
5330
|
+
// First, we want a dummy node with the same height as the `from` content.
|
|
5331
|
+
// We'll place the `to` node above the dummy to get the correct vertical alignment.
|
|
5332
|
+
let dummyNode;
|
|
5333
|
+
if (group.isCharacterBox) {
|
|
5334
|
+
dummyNode = new MathNode('mspace', []);
|
|
5335
|
+
dummyNode.setAttribute('height', "1em");
|
|
5336
|
+
} else {
|
|
5337
|
+
// Create a phantom node with the same content as the body.
|
|
5338
|
+
const inner = buildGroup$1(group.body, style);
|
|
5339
|
+
// The phantom node will be zero-width, so it won't affect horizontal spacing.
|
|
5340
|
+
const zeroWidthNode = new MathNode("mpadded", [inner]);
|
|
5341
|
+
zeroWidthNode.setAttribute("width", "0.1px"); // Don't use 0. WebKit would omit it.
|
|
5342
|
+
dummyNode = new MathNode("mphantom", [zeroWidthNode]); // Hide it.
|
|
5343
|
+
}
|
|
5344
|
+
const toNode = buildGroup$1(group.to, style);
|
|
5345
|
+
const zeroWidthToNode = new MathNode("mpadded", [toNode]);
|
|
5346
|
+
if (!group.isCharacterBox || /[f∫∑]/.test(group.body.body[0].text)) {
|
|
5347
|
+
const w = new MathNode("mspace", []);
|
|
5348
|
+
w.setAttribute('width', "0.2em");
|
|
5349
|
+
zeroWidthToNode.children.unshift(w);
|
|
5350
|
+
}
|
|
5351
|
+
zeroWidthToNode.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
5352
|
+
const mover = new MathNode("mover", [dummyNode, zeroWidthToNode]);
|
|
5353
|
+
// Fix Firefox positioning.
|
|
5354
|
+
const nudgeLeft = new MathNode('mrow', [], ["ff-nudge-left"]);
|
|
5355
|
+
return newDocumentFragment([makeRow([node, mover]), nudgeLeft])
|
|
5356
|
+
}
|
|
5357
|
+
});
|
|
5358
|
+
|
|
5306
5359
|
// \@char is an internal function that takes a grouped decimal argument like
|
|
5307
5360
|
// {123} and converts into symbol with code 123. It is used by the *macro*
|
|
5308
5361
|
// \char defined in macros.js.
|
|
@@ -5486,13 +5539,13 @@ var temml = (function () {
|
|
|
5486
5539
|
// the color individually to each node and return a document fragment.
|
|
5487
5540
|
let expr = buildExpression(group.body, style.withColor(group.color));
|
|
5488
5541
|
if (expr.length === 0) {
|
|
5489
|
-
expr.push(new
|
|
5542
|
+
expr.push(new MathNode("mrow"));
|
|
5490
5543
|
}
|
|
5491
5544
|
expr = expr.map(e => {
|
|
5492
5545
|
e.style.color = group.color;
|
|
5493
5546
|
return e
|
|
5494
5547
|
});
|
|
5495
|
-
return
|
|
5548
|
+
return newDocumentFragment(expr)
|
|
5496
5549
|
};
|
|
5497
5550
|
|
|
5498
5551
|
defineFunction({
|
|
@@ -5613,7 +5666,7 @@ var temml = (function () {
|
|
|
5613
5666
|
mathmlBuilder(group, style) {
|
|
5614
5667
|
// MathML 3.0 calls for newline to occur in an <mo> or an <mspace>.
|
|
5615
5668
|
// Ref: https://www.w3.org/TR/MathML3/chapter3.html#presm.linebreaking
|
|
5616
|
-
const node = new
|
|
5669
|
+
const node = new MathNode("mo");
|
|
5617
5670
|
if (group.newLine) {
|
|
5618
5671
|
node.setAttribute("linebreak", "newline");
|
|
5619
5672
|
if (group.size) {
|
|
@@ -6068,7 +6121,7 @@ var temml = (function () {
|
|
|
6068
6121
|
if (group.delim === ".") { group.delim = ""; }
|
|
6069
6122
|
children.push(makeText(group.delim, group.mode));
|
|
6070
6123
|
|
|
6071
|
-
const node = new
|
|
6124
|
+
const node = new MathNode("mo", children);
|
|
6072
6125
|
|
|
6073
6126
|
if (group.mclass === "mopen" || group.mclass === "mclose") {
|
|
6074
6127
|
// Only some of the delimsizing functions act as fences, and they
|
|
@@ -6162,7 +6215,7 @@ var temml = (function () {
|
|
|
6162
6215
|
const inner = buildExpression(group.body, style);
|
|
6163
6216
|
|
|
6164
6217
|
if (group.left === ".") { group.left = ""; }
|
|
6165
|
-
const leftNode = new
|
|
6218
|
+
const leftNode = new MathNode("mo", [makeText(group.left, group.mode)]);
|
|
6166
6219
|
leftNode.setAttribute("fence", "true");
|
|
6167
6220
|
leftNode.setAttribute("form", "prefix");
|
|
6168
6221
|
if (group.left === "/" || group.left === "\u005C" || group.left.indexOf("arrow") > -1) {
|
|
@@ -6171,7 +6224,7 @@ var temml = (function () {
|
|
|
6171
6224
|
inner.unshift(leftNode);
|
|
6172
6225
|
|
|
6173
6226
|
if (group.right === ".") { group.right = ""; }
|
|
6174
|
-
const rightNode = new
|
|
6227
|
+
const rightNode = new MathNode("mo", [makeText(group.right, group.mode)]);
|
|
6175
6228
|
rightNode.setAttribute("fence", "true");
|
|
6176
6229
|
rightNode.setAttribute("form", "postfix");
|
|
6177
6230
|
if (group.right === "\u2216" || group.right.indexOf("arrow") > -1) {
|
|
@@ -6213,7 +6266,7 @@ var temml = (function () {
|
|
|
6213
6266
|
},
|
|
6214
6267
|
mathmlBuilder: (group, style) => {
|
|
6215
6268
|
const textNode = makeText(group.delim, group.mode);
|
|
6216
|
-
const middleNode = new
|
|
6269
|
+
const middleNode = new MathNode("mo", [textNode]);
|
|
6217
6270
|
middleNode.setAttribute("fence", "true");
|
|
6218
6271
|
if (group.delim.indexOf("arrow") > -1) {
|
|
6219
6272
|
middleNode.setAttribute("stretchy", "true");
|
|
@@ -6229,8 +6282,11 @@ var temml = (function () {
|
|
|
6229
6282
|
}
|
|
6230
6283
|
});
|
|
6231
6284
|
|
|
6285
|
+
const boxTags = ["\\boxed", "\\fcolorbox", "\\colorbox"];
|
|
6286
|
+
|
|
6232
6287
|
const mathmlBuilder$7 = (group, style) => {
|
|
6233
|
-
const
|
|
6288
|
+
const tag = boxTags.includes(group.label) ? "mrow" : "menclose";
|
|
6289
|
+
const node = new MathNode(tag, [buildGroup$1(group.body, style)]);
|
|
6234
6290
|
switch (group.label) {
|
|
6235
6291
|
case "\\overline":
|
|
6236
6292
|
node.setAttribute("notation", "top"); // for Firefox & WebKit
|
|
@@ -6242,34 +6298,35 @@ var temml = (function () {
|
|
|
6242
6298
|
break
|
|
6243
6299
|
case "\\cancel":
|
|
6244
6300
|
node.setAttribute("notation", "updiagonalstrike");
|
|
6245
|
-
node.children.push(new
|
|
6301
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "upstrike"]));
|
|
6246
6302
|
break
|
|
6247
6303
|
case "\\bcancel":
|
|
6248
6304
|
node.setAttribute("notation", "downdiagonalstrike");
|
|
6249
|
-
node.children.push(new
|
|
6305
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "downstrike"]));
|
|
6250
6306
|
break
|
|
6251
6307
|
case "\\sout":
|
|
6252
6308
|
node.setAttribute("notation", "horizontalstrike");
|
|
6253
|
-
node.children.push(new
|
|
6309
|
+
node.children.push(new MathNode("mrow", [], ["tml-cancel", "sout"]));
|
|
6254
6310
|
break
|
|
6255
6311
|
case "\\xcancel":
|
|
6256
6312
|
node.setAttribute("notation", "updiagonalstrike downdiagonalstrike");
|
|
6257
6313
|
node.classes.push("tml-xcancel");
|
|
6258
6314
|
break
|
|
6315
|
+
// cancelto is handled in cancelto.js
|
|
6259
6316
|
case "\\longdiv":
|
|
6260
6317
|
node.setAttribute("notation", "longdiv");
|
|
6261
6318
|
node.classes.push("longdiv-top");
|
|
6262
|
-
node.children.push(new
|
|
6319
|
+
node.children.push(new MathNode("mrow", [], ["longdiv-arc"]));
|
|
6263
6320
|
break
|
|
6264
6321
|
case "\\phase":
|
|
6265
6322
|
node.setAttribute("notation", "phasorangle");
|
|
6266
6323
|
node.classes.push("phasor-bottom");
|
|
6267
|
-
node.children.push(new
|
|
6324
|
+
node.children.push(new MathNode("mrow", [], ["phasor-angle"]));
|
|
6268
6325
|
break
|
|
6269
6326
|
case "\\textcircled":
|
|
6270
6327
|
node.setAttribute("notation", "circle");
|
|
6271
6328
|
node.classes.push("circle-pad");
|
|
6272
|
-
node.children.push(new
|
|
6329
|
+
node.children.push(new MathNode("mrow", [], ["textcircle"]));
|
|
6273
6330
|
break
|
|
6274
6331
|
case "\\angl":
|
|
6275
6332
|
node.setAttribute("notation", "actuarial");
|
|
@@ -6277,7 +6334,6 @@ var temml = (function () {
|
|
|
6277
6334
|
break
|
|
6278
6335
|
case "\\boxed":
|
|
6279
6336
|
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
|
|
6280
|
-
node.setAttribute("notation", "box");
|
|
6281
6337
|
node.style.padding = "3pt";
|
|
6282
6338
|
node.style.border = "1px solid";
|
|
6283
6339
|
node.setAttribute("scriptlevel", "0");
|
|
@@ -6289,13 +6345,8 @@ var temml = (function () {
|
|
|
6289
6345
|
break
|
|
6290
6346
|
case "\\fcolorbox":
|
|
6291
6347
|
case "\\colorbox": {
|
|
6292
|
-
//
|
|
6293
|
-
//
|
|
6294
|
-
// included with <menclose>.
|
|
6295
|
-
//const fboxsep = 3; // 3 pt from LaTeX source2e
|
|
6296
|
-
//node.setAttribute("height", `+${2 * fboxsep}pt`)
|
|
6297
|
-
//node.setAttribute("voffset", `${fboxsep}pt`)
|
|
6298
|
-
node.style.padding = "3pt";
|
|
6348
|
+
// Don't use <menclose>. WebKit would show a radical.
|
|
6349
|
+
node.style.padding = "0.3em"; // 3 pt from LaTeX source2e for a 10pt font
|
|
6299
6350
|
if (group.label === "\\fcolorbox") {
|
|
6300
6351
|
node.style.border = "0.0667em solid " + String(group.borderColor);
|
|
6301
6352
|
}
|
|
@@ -6521,7 +6572,7 @@ var temml = (function () {
|
|
|
6521
6572
|
};
|
|
6522
6573
|
},
|
|
6523
6574
|
mathmlBuilder(group, style) {
|
|
6524
|
-
return new
|
|
6575
|
+
return new MathNode("mrow");
|
|
6525
6576
|
}
|
|
6526
6577
|
});
|
|
6527
6578
|
|
|
@@ -6538,7 +6589,7 @@ var temml = (function () {
|
|
|
6538
6589
|
};
|
|
6539
6590
|
},
|
|
6540
6591
|
mathmlBuilder(group, style) {
|
|
6541
|
-
return new
|
|
6592
|
+
return new MathNode("mrow");
|
|
6542
6593
|
}
|
|
6543
6594
|
});
|
|
6544
6595
|
|
|
@@ -6581,7 +6632,7 @@ var temml = (function () {
|
|
|
6581
6632
|
: mathGroup.children[i].children[0].text;
|
|
6582
6633
|
}
|
|
6583
6634
|
// Wrap in a <mpadded> to prevent the same Firefox bug.
|
|
6584
|
-
const mpadded = new
|
|
6635
|
+
const mpadded = new MathNode("mpadded", [mi]);
|
|
6585
6636
|
mpadded.setAttribute("lspace", "0");
|
|
6586
6637
|
return mpadded
|
|
6587
6638
|
}
|
|
@@ -6607,8 +6658,8 @@ var temml = (function () {
|
|
|
6607
6658
|
// Ref: https://bugs.webkit.org/show_bug.cgi?id=129097
|
|
6608
6659
|
// We insert a text node that contains a zero-width space and wrap in an mrow.
|
|
6609
6660
|
// TODO: Get rid of this <mi> workaround when the Firefox bug is fixed.
|
|
6610
|
-
const bogus = new
|
|
6611
|
-
return new
|
|
6661
|
+
const bogus = new MathNode("mtext", new TextNode("\u200b"));
|
|
6662
|
+
return new MathNode("mrow", [bogus, mi])
|
|
6612
6663
|
}
|
|
6613
6664
|
return mi
|
|
6614
6665
|
};
|
|
@@ -6719,7 +6770,7 @@ var temml = (function () {
|
|
|
6719
6770
|
denom.setAttribute("scriptlevel", "2");
|
|
6720
6771
|
}
|
|
6721
6772
|
|
|
6722
|
-
let node = new
|
|
6773
|
+
let node = new MathNode("mfrac", [numer, denom]);
|
|
6723
6774
|
|
|
6724
6775
|
if (!group.hasBarLine) {
|
|
6725
6776
|
node.setAttribute("linethickness", "0px");
|
|
@@ -6732,8 +6783,8 @@ var temml = (function () {
|
|
|
6732
6783
|
const withDelims = [];
|
|
6733
6784
|
|
|
6734
6785
|
if (group.leftDelim != null) {
|
|
6735
|
-
const leftOp = new
|
|
6736
|
-
new
|
|
6786
|
+
const leftOp = new MathNode("mo", [
|
|
6787
|
+
new TextNode(group.leftDelim.replace("\\", ""))
|
|
6737
6788
|
]);
|
|
6738
6789
|
leftOp.setAttribute("fence", "true");
|
|
6739
6790
|
withDelims.push(leftOp);
|
|
@@ -6742,8 +6793,8 @@ var temml = (function () {
|
|
|
6742
6793
|
withDelims.push(node);
|
|
6743
6794
|
|
|
6744
6795
|
if (group.rightDelim != null) {
|
|
6745
|
-
const rightOp = new
|
|
6746
|
-
new
|
|
6796
|
+
const rightOp = new MathNode("mo", [
|
|
6797
|
+
new TextNode(group.rightDelim.replace("\\", ""))
|
|
6747
6798
|
]);
|
|
6748
6799
|
rightOp.setAttribute("fence", "true");
|
|
6749
6800
|
withDelims.push(rightOp);
|
|
@@ -6753,7 +6804,7 @@ var temml = (function () {
|
|
|
6753
6804
|
}
|
|
6754
6805
|
|
|
6755
6806
|
if (group.scriptLevel !== "auto") {
|
|
6756
|
-
node = new
|
|
6807
|
+
node = new MathNode("mstyle", [node]);
|
|
6757
6808
|
node.setAttribute("displaystyle", String(group.scriptLevel === "display"));
|
|
6758
6809
|
node.setAttribute("scriptlevel", scriptLevel[group.scriptLevel]);
|
|
6759
6810
|
}
|
|
@@ -7056,24 +7107,24 @@ var temml = (function () {
|
|
|
7056
7107
|
});
|
|
7057
7108
|
|
|
7058
7109
|
const mathmlBuilder$4 = (group, style) => {
|
|
7059
|
-
const accentNode =
|
|
7110
|
+
const accentNode = mathMLnode(group.label);
|
|
7060
7111
|
accentNode.style["math-depth"] = 0;
|
|
7061
|
-
return new
|
|
7112
|
+
return new MathNode(group.isOver ? "mover" : "munder", [
|
|
7062
7113
|
buildGroup$1(group.base, style),
|
|
7063
7114
|
accentNode
|
|
7064
7115
|
]);
|
|
7065
7116
|
};
|
|
7066
7117
|
|
|
7067
|
-
// Horizontal stretchy
|
|
7118
|
+
// Horizontal stretchy brackets
|
|
7068
7119
|
defineFunction({
|
|
7069
|
-
type: "
|
|
7070
|
-
names: ["\\overbrace", "\\underbrace"],
|
|
7120
|
+
type: "horizBracket",
|
|
7121
|
+
names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"],
|
|
7071
7122
|
props: {
|
|
7072
7123
|
numArgs: 1
|
|
7073
7124
|
},
|
|
7074
7125
|
handler({ parser, funcName }, args) {
|
|
7075
7126
|
return {
|
|
7076
|
-
type: "
|
|
7127
|
+
type: "horizBracket",
|
|
7077
7128
|
mode: parser.mode,
|
|
7078
7129
|
label: funcName,
|
|
7079
7130
|
isOver: /^\\over/.test(funcName),
|
|
@@ -7294,7 +7345,7 @@ var temml = (function () {
|
|
|
7294
7345
|
const node = new Img(group.src, group.alt, graphicStyle);
|
|
7295
7346
|
node.height = height;
|
|
7296
7347
|
node.depth = depth;
|
|
7297
|
-
return new
|
|
7348
|
+
return new MathNode("mtext", [node])
|
|
7298
7349
|
}
|
|
7299
7350
|
});
|
|
7300
7351
|
|
|
@@ -7344,17 +7395,17 @@ var temml = (function () {
|
|
|
7344
7395
|
? spaceCharacter(dimension.number)
|
|
7345
7396
|
: "";
|
|
7346
7397
|
if (group.mode === "text" && ch.length > 0) {
|
|
7347
|
-
const character = new
|
|
7348
|
-
return new
|
|
7398
|
+
const character = new TextNode(ch);
|
|
7399
|
+
return new MathNode("mtext", [character]);
|
|
7349
7400
|
} else {
|
|
7350
7401
|
if (dimension.number >= 0) {
|
|
7351
|
-
const node = new
|
|
7402
|
+
const node = new MathNode("mspace");
|
|
7352
7403
|
node.setAttribute("width", dimension.number + dimension.unit);
|
|
7353
7404
|
return node
|
|
7354
7405
|
} else {
|
|
7355
7406
|
// Don't use <mspace> or <mpadded> because
|
|
7356
7407
|
// WebKit recognizes negative left margin only on a <mrow> element
|
|
7357
|
-
const node = new
|
|
7408
|
+
const node = new MathNode("mrow");
|
|
7358
7409
|
node.style.marginLeft = dimension.number + dimension.unit;
|
|
7359
7410
|
return node
|
|
7360
7411
|
}
|
|
@@ -7395,7 +7446,7 @@ var temml = (function () {
|
|
|
7395
7446
|
},
|
|
7396
7447
|
mathmlBuilder(group, style) {
|
|
7397
7448
|
// Return a no-width, no-ink element with an HTML id.
|
|
7398
|
-
const node = new
|
|
7449
|
+
const node = new MathNode("mrow", [], ["tml-label"]);
|
|
7399
7450
|
if (group.string.length > 0) {
|
|
7400
7451
|
node.setLabel(group.string);
|
|
7401
7452
|
}
|
|
@@ -7439,8 +7490,8 @@ var temml = (function () {
|
|
|
7439
7490
|
// We need an invisible strut with the same depth as the group.
|
|
7440
7491
|
// We can't just read the depth, so we use \vphantom methods.
|
|
7441
7492
|
const phantomInner = buildExpression(ordargument(group.body), style);
|
|
7442
|
-
const phantom = new
|
|
7443
|
-
strut = new
|
|
7493
|
+
const phantom = new MathNode("mphantom", phantomInner);
|
|
7494
|
+
strut = new MathNode("mpadded", [phantom]);
|
|
7444
7495
|
strut.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
|
|
7445
7496
|
}
|
|
7446
7497
|
|
|
@@ -7450,9 +7501,9 @@ var temml = (function () {
|
|
|
7450
7501
|
inner.style.position = "absolute";
|
|
7451
7502
|
inner.style.right = "0";
|
|
7452
7503
|
inner.style.bottom = `0`; // If we could have read the ink depth, it would go here.
|
|
7453
|
-
node = new
|
|
7504
|
+
node = new MathNode("mpadded", [strut, inner]);
|
|
7454
7505
|
} else {
|
|
7455
|
-
node = new
|
|
7506
|
+
node = new MathNode("mpadded", [inner]);
|
|
7456
7507
|
}
|
|
7457
7508
|
|
|
7458
7509
|
if (group.alignment === "rlap") {
|
|
@@ -7558,7 +7609,7 @@ var temml = (function () {
|
|
|
7558
7609
|
const inner = buildExpression(group.body, style);
|
|
7559
7610
|
|
|
7560
7611
|
if (group.mclass === "minner") {
|
|
7561
|
-
node = new
|
|
7612
|
+
node = new MathNode("mpadded", inner);
|
|
7562
7613
|
} else if (group.mclass === "mord") {
|
|
7563
7614
|
if (group.isCharacterBox || inner[0].type === "mathord") {
|
|
7564
7615
|
node = inner[0];
|
|
@@ -7567,10 +7618,10 @@ var temml = (function () {
|
|
|
7567
7618
|
node.setAttribute("mathvariant", "normal");
|
|
7568
7619
|
}
|
|
7569
7620
|
} else {
|
|
7570
|
-
node = new
|
|
7621
|
+
node = new MathNode("mi", inner);
|
|
7571
7622
|
}
|
|
7572
7623
|
} else {
|
|
7573
|
-
node = new
|
|
7624
|
+
node = new MathNode("mrow", inner);
|
|
7574
7625
|
if (group.mustPromote) {
|
|
7575
7626
|
node = inner[0];
|
|
7576
7627
|
node.type = "mo";
|
|
@@ -7578,7 +7629,7 @@ var temml = (function () {
|
|
|
7578
7629
|
node.setAttribute("mathvariant", "italic");
|
|
7579
7630
|
}
|
|
7580
7631
|
} else {
|
|
7581
|
-
node = new
|
|
7632
|
+
node = new MathNode("mrow", inner);
|
|
7582
7633
|
}
|
|
7583
7634
|
|
|
7584
7635
|
// Set spacing based on what is the most likely adjacent atom type.
|
|
@@ -7648,7 +7699,7 @@ var temml = (function () {
|
|
|
7648
7699
|
},
|
|
7649
7700
|
handler({ parser, funcName }, args) {
|
|
7650
7701
|
const body = args[0];
|
|
7651
|
-
const isCharacterBox =
|
|
7702
|
+
const isCharacterBox$1 = isCharacterBox(body);
|
|
7652
7703
|
// We should not wrap a <mo> around a <mi> or <mord>. That would be invalid MathML.
|
|
7653
7704
|
// In that case, we instead promote the text contents of the body to the parent.
|
|
7654
7705
|
let mustPromote = true;
|
|
@@ -7677,7 +7728,7 @@ var temml = (function () {
|
|
|
7677
7728
|
mode: parser.mode,
|
|
7678
7729
|
mclass: "m" + funcName.slice(5),
|
|
7679
7730
|
body: ordargument(mustPromote ? mord : body),
|
|
7680
|
-
isCharacterBox,
|
|
7731
|
+
isCharacterBox: isCharacterBox$1,
|
|
7681
7732
|
mustPromote
|
|
7682
7733
|
};
|
|
7683
7734
|
}
|
|
@@ -7714,7 +7765,7 @@ var temml = (function () {
|
|
|
7714
7765
|
mode: parser.mode,
|
|
7715
7766
|
mclass: binrelClass(args[0]),
|
|
7716
7767
|
body: ordargument(args[1]),
|
|
7717
|
-
isCharacterBox:
|
|
7768
|
+
isCharacterBox: isCharacterBox(args[1])
|
|
7718
7769
|
};
|
|
7719
7770
|
}
|
|
7720
7771
|
});
|
|
@@ -7828,8 +7879,8 @@ var temml = (function () {
|
|
|
7828
7879
|
mathmlBuilder(group, style) {
|
|
7829
7880
|
const base = buildGroup$1(group.base, style);
|
|
7830
7881
|
|
|
7831
|
-
const prescriptsNode = new
|
|
7832
|
-
const noneNode = new
|
|
7882
|
+
const prescriptsNode = new MathNode("mprescripts");
|
|
7883
|
+
const noneNode = new MathNode("none");
|
|
7833
7884
|
let children = [];
|
|
7834
7885
|
|
|
7835
7886
|
const preSub = buildGroup(group.prescripts.sub, style, noneNode);
|
|
@@ -7848,7 +7899,7 @@ var temml = (function () {
|
|
|
7848
7899
|
children = [base, prescriptsNode, preSub, preSup];
|
|
7849
7900
|
}
|
|
7850
7901
|
|
|
7851
|
-
return new
|
|
7902
|
+
return new MathNode("mmultiscripts", children);
|
|
7852
7903
|
}
|
|
7853
7904
|
});
|
|
7854
7905
|
|
|
@@ -7861,9 +7912,9 @@ var temml = (function () {
|
|
|
7861
7912
|
allowedInText: false
|
|
7862
7913
|
},
|
|
7863
7914
|
handler({ parser }, args) {
|
|
7864
|
-
const isCharacterBox =
|
|
7915
|
+
const isCharacterBox$1 = isCharacterBox(args[0]);
|
|
7865
7916
|
let body;
|
|
7866
|
-
if (isCharacterBox) {
|
|
7917
|
+
if (isCharacterBox$1) {
|
|
7867
7918
|
body = ordargument(args[0]);
|
|
7868
7919
|
if (body[0].text.charAt(0) === "\\") {
|
|
7869
7920
|
body[0].text = symbols.math[body[0].text].replace;
|
|
@@ -7881,7 +7932,7 @@ var temml = (function () {
|
|
|
7881
7932
|
type: "not",
|
|
7882
7933
|
mode: parser.mode,
|
|
7883
7934
|
body,
|
|
7884
|
-
isCharacterBox
|
|
7935
|
+
isCharacterBox: isCharacterBox$1
|
|
7885
7936
|
};
|
|
7886
7937
|
},
|
|
7887
7938
|
mathmlBuilder(group, style) {
|
|
@@ -8229,7 +8280,8 @@ var temml = (function () {
|
|
|
8229
8280
|
"\u2a1a"
|
|
8230
8281
|
],
|
|
8231
8282
|
props: {
|
|
8232
|
-
numArgs: 0
|
|
8283
|
+
numArgs: 0,
|
|
8284
|
+
allowedInArgument: true
|
|
8233
8285
|
},
|
|
8234
8286
|
handler({ parser, funcName }) {
|
|
8235
8287
|
let fName = funcName;
|
|
@@ -8260,9 +8312,9 @@ var temml = (function () {
|
|
|
8260
8312
|
let isAllString = true; // default
|
|
8261
8313
|
for (let i = 0; i < expression.length; i++) {
|
|
8262
8314
|
let node = expression[i];
|
|
8263
|
-
if (node instanceof
|
|
8315
|
+
if (node instanceof MathNode) {
|
|
8264
8316
|
if ((node.type === "mrow" || node.type === "mpadded") && node.children.length === 1 &&
|
|
8265
|
-
node.children[0] instanceof
|
|
8317
|
+
node.children[0] instanceof MathNode) {
|
|
8266
8318
|
node = node.children[0];
|
|
8267
8319
|
}
|
|
8268
8320
|
switch (node.type) {
|
|
@@ -8279,14 +8331,14 @@ var temml = (function () {
|
|
|
8279
8331
|
if (ch === "") {
|
|
8280
8332
|
isAllString = false;
|
|
8281
8333
|
} else {
|
|
8282
|
-
expression[i] = new
|
|
8334
|
+
expression[i] = new MathNode("mtext", [new TextNode(ch)]);
|
|
8283
8335
|
}
|
|
8284
8336
|
}
|
|
8285
8337
|
}
|
|
8286
8338
|
break
|
|
8287
8339
|
case "mo": {
|
|
8288
8340
|
const child = node.children[0];
|
|
8289
|
-
if (node.children.length === 1 && child instanceof
|
|
8341
|
+
if (node.children.length === 1 && child instanceof TextNode) {
|
|
8290
8342
|
child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*");
|
|
8291
8343
|
} else {
|
|
8292
8344
|
isAllString = false;
|
|
@@ -8304,7 +8356,7 @@ var temml = (function () {
|
|
|
8304
8356
|
if (isAllString) {
|
|
8305
8357
|
// Write a single TextNode instead of multiple nested tags.
|
|
8306
8358
|
const word = expression.map((node) => node.toText()).join("");
|
|
8307
|
-
expression = [new
|
|
8359
|
+
expression = [new TextNode(word)];
|
|
8308
8360
|
} else if (
|
|
8309
8361
|
expression.length === 1
|
|
8310
8362
|
&& ["mover", "munder"].includes(expression[0].type) &&
|
|
@@ -8312,41 +8364,41 @@ var temml = (function () {
|
|
|
8312
8364
|
) {
|
|
8313
8365
|
expression[0].children[0].type = "mi";
|
|
8314
8366
|
if (group.parentIsSupSub) {
|
|
8315
|
-
return new
|
|
8367
|
+
return new MathNode("mrow", expression)
|
|
8316
8368
|
} else {
|
|
8317
|
-
const operator = new
|
|
8318
|
-
return
|
|
8369
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
8370
|
+
return newDocumentFragment([expression[0], operator])
|
|
8319
8371
|
}
|
|
8320
8372
|
}
|
|
8321
8373
|
|
|
8322
8374
|
let wrapper;
|
|
8323
8375
|
if (isAllString) {
|
|
8324
|
-
wrapper = new
|
|
8376
|
+
wrapper = new MathNode("mi", expression);
|
|
8325
8377
|
if (expression[0].text.length === 1) {
|
|
8326
8378
|
wrapper.setAttribute("mathvariant", "normal");
|
|
8327
8379
|
}
|
|
8328
8380
|
} else {
|
|
8329
|
-
wrapper = new
|
|
8381
|
+
wrapper = new MathNode("mrow", expression);
|
|
8330
8382
|
}
|
|
8331
8383
|
|
|
8332
8384
|
if (!group.parentIsSupSub) {
|
|
8333
8385
|
// Append an <mo>⁡</mo>.
|
|
8334
8386
|
// ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
|
|
8335
|
-
const operator = new
|
|
8387
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
8336
8388
|
const fragment = [wrapper, operator];
|
|
8337
8389
|
if (group.needsLeadingSpace) {
|
|
8338
8390
|
// LaTeX gives operator spacing, but a <mi> gets ord spacing.
|
|
8339
8391
|
// So add a leading space.
|
|
8340
|
-
const space = new
|
|
8392
|
+
const space = new MathNode("mspace");
|
|
8341
8393
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
8342
8394
|
fragment.unshift(space);
|
|
8343
8395
|
}
|
|
8344
8396
|
if (!group.isFollowedByDelimiter) {
|
|
8345
|
-
const trail = new
|
|
8397
|
+
const trail = new MathNode("mspace");
|
|
8346
8398
|
trail.setAttribute("width", "0.1667em"); // thin space.
|
|
8347
8399
|
fragment.push(trail);
|
|
8348
8400
|
}
|
|
8349
|
-
return
|
|
8401
|
+
return newDocumentFragment(fragment)
|
|
8350
8402
|
}
|
|
8351
8403
|
|
|
8352
8404
|
return wrapper
|
|
@@ -8406,7 +8458,7 @@ var temml = (function () {
|
|
|
8406
8458
|
},
|
|
8407
8459
|
mathmlBuilder: (group, style) => {
|
|
8408
8460
|
const inner = buildExpression(group.body, style);
|
|
8409
|
-
return new
|
|
8461
|
+
return new MathNode("mphantom", inner);
|
|
8410
8462
|
}
|
|
8411
8463
|
});
|
|
8412
8464
|
|
|
@@ -8427,8 +8479,8 @@ var temml = (function () {
|
|
|
8427
8479
|
},
|
|
8428
8480
|
mathmlBuilder: (group, style) => {
|
|
8429
8481
|
const inner = buildExpression(ordargument(group.body), style);
|
|
8430
|
-
const phantom = new
|
|
8431
|
-
const node = new
|
|
8482
|
+
const phantom = new MathNode("mphantom", inner);
|
|
8483
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
8432
8484
|
node.setAttribute("height", "0px");
|
|
8433
8485
|
node.setAttribute("depth", "0px");
|
|
8434
8486
|
return node;
|
|
@@ -8452,8 +8504,8 @@ var temml = (function () {
|
|
|
8452
8504
|
},
|
|
8453
8505
|
mathmlBuilder: (group, style) => {
|
|
8454
8506
|
const inner = buildExpression(ordargument(group.body), style);
|
|
8455
|
-
const phantom = new
|
|
8456
|
-
const node = new
|
|
8507
|
+
const phantom = new MathNode("mphantom", inner);
|
|
8508
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
8457
8509
|
node.setAttribute("width", "0px");
|
|
8458
8510
|
return node;
|
|
8459
8511
|
}
|
|
@@ -8490,7 +8542,7 @@ var temml = (function () {
|
|
|
8490
8542
|
|
|
8491
8543
|
const mathmlBuilder = (group, style) => {
|
|
8492
8544
|
const newStyle = style.withLevel(StyleLevel.TEXT);
|
|
8493
|
-
const node = new
|
|
8545
|
+
const node = new MathNode("mpadded", [buildGroup$1(group.body, newStyle)]);
|
|
8494
8546
|
const dy = calculateSize(group.dy, style);
|
|
8495
8547
|
node.setAttribute("voffset", dy.number + dy.unit);
|
|
8496
8548
|
// Add padding, which acts to increase height in Chromium.
|
|
@@ -8638,7 +8690,7 @@ var temml = (function () {
|
|
|
8638
8690
|
: { number: 0, unit: "em" };
|
|
8639
8691
|
const color = (style.color && style.getColor()) || "black";
|
|
8640
8692
|
|
|
8641
|
-
const rule = new
|
|
8693
|
+
const rule = new MathNode("mspace");
|
|
8642
8694
|
if (width.number > 0 && height.number > 0) {
|
|
8643
8695
|
rule.setAttribute("mathbackground", color);
|
|
8644
8696
|
}
|
|
@@ -8646,7 +8698,7 @@ var temml = (function () {
|
|
|
8646
8698
|
rule.setAttribute("height", height.number + height.unit);
|
|
8647
8699
|
if (shift.number === 0) { return rule }
|
|
8648
8700
|
|
|
8649
|
-
const wrapper = new
|
|
8701
|
+
const wrapper = new MathNode("mpadded", [rule]);
|
|
8650
8702
|
if (shift.number >= 0) {
|
|
8651
8703
|
wrapper.setAttribute("height", "+" + shift.number + shift.unit);
|
|
8652
8704
|
} else {
|
|
@@ -8718,8 +8770,8 @@ var temml = (function () {
|
|
|
8718
8770
|
const numerator = group.numerator.split('').map(c => unicodeNumSups[c]).join('');
|
|
8719
8771
|
const denominator = group.denominator.split('').map(c => unicodeNumSubs[c]).join('');
|
|
8720
8772
|
// Use a fraction slash.
|
|
8721
|
-
const text = new
|
|
8722
|
-
return new
|
|
8773
|
+
const text = new TextNode(numerator + "\u2044" + denominator, group.mode, style);
|
|
8774
|
+
return new MathNode("mn", [text], ["special-fraction"])
|
|
8723
8775
|
}
|
|
8724
8776
|
});
|
|
8725
8777
|
|
|
@@ -8832,7 +8884,7 @@ var temml = (function () {
|
|
|
8832
8884
|
};
|
|
8833
8885
|
},
|
|
8834
8886
|
mathmlBuilder: (group, style) => {
|
|
8835
|
-
const node = new
|
|
8887
|
+
const node = new MathNode("mpadded", [buildGroup$1(group.body, style)]);
|
|
8836
8888
|
|
|
8837
8889
|
if (group.smashHeight) {
|
|
8838
8890
|
node.setAttribute("height", "0px");
|
|
@@ -8885,11 +8937,11 @@ var temml = (function () {
|
|
|
8885
8937
|
mathmlBuilder(group, style) {
|
|
8886
8938
|
const { body, index } = group;
|
|
8887
8939
|
return index
|
|
8888
|
-
? new
|
|
8940
|
+
? new MathNode("mroot", [
|
|
8889
8941
|
buildGroup$1(body, style),
|
|
8890
8942
|
buildGroup$1(index, style.incrementLevel())
|
|
8891
8943
|
])
|
|
8892
|
-
: new
|
|
8944
|
+
: new MathNode("msqrt", [buildGroup$1(body, style)]);
|
|
8893
8945
|
}
|
|
8894
8946
|
});
|
|
8895
8947
|
|
|
@@ -8969,18 +9021,18 @@ var temml = (function () {
|
|
|
8969
9021
|
defineFunctionBuilders({
|
|
8970
9022
|
type: "supsub",
|
|
8971
9023
|
mathmlBuilder(group, style) {
|
|
8972
|
-
// Is the inner group a relevant horizontal brace?
|
|
8973
|
-
let
|
|
9024
|
+
// Is the inner group a relevant horizontal brace or bracket?
|
|
9025
|
+
let isBracket = false;
|
|
8974
9026
|
let isOver;
|
|
8975
9027
|
let isSup;
|
|
8976
9028
|
let appendApplyFunction = false;
|
|
8977
9029
|
let appendSpace = false;
|
|
8978
9030
|
let needsLeadingSpace = false;
|
|
8979
9031
|
|
|
8980
|
-
if (group.base && group.base.type === "
|
|
9032
|
+
if (group.base && group.base.type === "horizBracket") {
|
|
8981
9033
|
isSup = !!group.sup;
|
|
8982
9034
|
if (isSup === group.base.isOver) {
|
|
8983
|
-
|
|
9035
|
+
isBracket = true;
|
|
8984
9036
|
isOver = group.base.isOver;
|
|
8985
9037
|
}
|
|
8986
9038
|
}
|
|
@@ -9028,7 +9080,7 @@ var temml = (function () {
|
|
|
9028
9080
|
}
|
|
9029
9081
|
|
|
9030
9082
|
let nodeType;
|
|
9031
|
-
if (
|
|
9083
|
+
if (isBracket) {
|
|
9032
9084
|
nodeType = isOver ? "mover" : "munder";
|
|
9033
9085
|
} else if (!group.sub) {
|
|
9034
9086
|
const base = group.base;
|
|
@@ -9088,26 +9140,26 @@ var temml = (function () {
|
|
|
9088
9140
|
}
|
|
9089
9141
|
}
|
|
9090
9142
|
|
|
9091
|
-
let node = new
|
|
9143
|
+
let node = new MathNode(nodeType, children);
|
|
9092
9144
|
if (appendApplyFunction) {
|
|
9093
9145
|
// Append an <mo>⁡</mo>.
|
|
9094
9146
|
// ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
|
|
9095
|
-
const operator = new
|
|
9147
|
+
const operator = new MathNode("mo", [makeText("\u2061", "text")]);
|
|
9096
9148
|
if (needsLeadingSpace) {
|
|
9097
|
-
const space = new
|
|
9149
|
+
const space = new MathNode("mspace");
|
|
9098
9150
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
9099
|
-
node =
|
|
9151
|
+
node = newDocumentFragment([space, node, operator]);
|
|
9100
9152
|
} else {
|
|
9101
|
-
node =
|
|
9153
|
+
node = newDocumentFragment([node, operator]);
|
|
9102
9154
|
}
|
|
9103
9155
|
if (appendSpace) {
|
|
9104
|
-
const space = new
|
|
9156
|
+
const space = new MathNode("mspace");
|
|
9105
9157
|
space.setAttribute("width", "0.1667em"); // thin space.
|
|
9106
9158
|
node.children.push(space);
|
|
9107
9159
|
}
|
|
9108
9160
|
} else if (symbolRegEx.test(nodeType)) {
|
|
9109
9161
|
// Wrap in a <mrow>. Otherwise Firefox stretchy parens will not stretch to include limits.
|
|
9110
|
-
node = new
|
|
9162
|
+
node = new MathNode("mrow", [node]);
|
|
9111
9163
|
}
|
|
9112
9164
|
|
|
9113
9165
|
return node
|
|
@@ -9132,7 +9184,7 @@ var temml = (function () {
|
|
|
9132
9184
|
defineFunctionBuilders({
|
|
9133
9185
|
type: "atom",
|
|
9134
9186
|
mathmlBuilder(group, style) {
|
|
9135
|
-
const node = new
|
|
9187
|
+
const node = new MathNode("mo", [makeText(group.text, group.mode)]);
|
|
9136
9188
|
if (group.family === "punct") {
|
|
9137
9189
|
node.setAttribute("separator", "true");
|
|
9138
9190
|
} else if (group.family === "open" || group.family === "close") {
|
|
@@ -9162,10 +9214,10 @@ var temml = (function () {
|
|
|
9162
9214
|
} else if (group.needsSpacing) {
|
|
9163
9215
|
// Fix a MathML bug that occurs when a <mo> is between two <mtext> elements.
|
|
9164
9216
|
if (group.family === "bin") {
|
|
9165
|
-
return new
|
|
9217
|
+
return new MathNode("mrow", [padding(0.222), node, padding(0.222)])
|
|
9166
9218
|
} else {
|
|
9167
9219
|
// REL spacing
|
|
9168
|
-
return new
|
|
9220
|
+
return new MathNode("mrow", [padding(0.2778), node, padding(0.2778)])
|
|
9169
9221
|
}
|
|
9170
9222
|
}
|
|
9171
9223
|
return node;
|
|
@@ -9506,8 +9558,8 @@ var temml = (function () {
|
|
|
9506
9558
|
"\\backprime", "\\backdprime", "\\backtrprime"]);
|
|
9507
9559
|
|
|
9508
9560
|
const italicNumber = (text, variant, tag) => {
|
|
9509
|
-
const mn = new
|
|
9510
|
-
const wrapper = new
|
|
9561
|
+
const mn = new MathNode(tag, [text]);
|
|
9562
|
+
const wrapper = new MathNode("mstyle", [mn]);
|
|
9511
9563
|
wrapper.style["font-style"] = "italic";
|
|
9512
9564
|
wrapper.style["font-family"] = "Cambria, 'Times New Roman', serif";
|
|
9513
9565
|
if (variant === "bold-italic") { wrapper.style["font-weight"] = "bold"; }
|
|
@@ -9524,17 +9576,17 @@ var temml = (function () {
|
|
|
9524
9576
|
const variant = getVariant(group, style) || defaultVariant;
|
|
9525
9577
|
if (variant === "script") {
|
|
9526
9578
|
text.text = variantChar(text.text, variant);
|
|
9527
|
-
return new
|
|
9579
|
+
return new MathNode("mi", [text], [style.font])
|
|
9528
9580
|
} else if (variant !== "italic") {
|
|
9529
9581
|
text.text = variantChar(text.text, variant);
|
|
9530
9582
|
}
|
|
9531
|
-
let node = new
|
|
9583
|
+
let node = new MathNode("mi", [text]);
|
|
9532
9584
|
// TODO: Handle U+1D49C - U+1D4CF per https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
9533
9585
|
if (variant === "normal") {
|
|
9534
9586
|
node.setAttribute("mathvariant", "normal");
|
|
9535
9587
|
if (text.text.length === 1) {
|
|
9536
9588
|
// A Firefox bug will apply spacing here, but there should be none. Fix it.
|
|
9537
|
-
node = new
|
|
9589
|
+
node = new MathNode("mpadded", [node]);
|
|
9538
9590
|
node.setAttribute("lspace", "0");
|
|
9539
9591
|
}
|
|
9540
9592
|
}
|
|
@@ -9565,15 +9617,15 @@ var temml = (function () {
|
|
|
9565
9617
|
if (variant !== "normal") {
|
|
9566
9618
|
text.text = text.text.split("").map(c => variantChar(c, variant)).join("");
|
|
9567
9619
|
}
|
|
9568
|
-
node = new
|
|
9620
|
+
node = new MathNode(tag, [text]);
|
|
9569
9621
|
}
|
|
9570
9622
|
} else if (group.mode === "text") {
|
|
9571
9623
|
if (variant !== "normal") {
|
|
9572
9624
|
text.text = variantChar(text.text, variant);
|
|
9573
9625
|
}
|
|
9574
|
-
node = new
|
|
9626
|
+
node = new MathNode("mtext", [text]);
|
|
9575
9627
|
} else if (primes.has(group.text)) {
|
|
9576
|
-
node = new
|
|
9628
|
+
node = new MathNode("mo", [text]);
|
|
9577
9629
|
// TODO: If/when Chromium uses ssty variant for prime, remove the next line.
|
|
9578
9630
|
node.classes.push("tml-prime");
|
|
9579
9631
|
} else {
|
|
@@ -9581,7 +9633,7 @@ var temml = (function () {
|
|
|
9581
9633
|
if (variant !== "italic") {
|
|
9582
9634
|
text.text = variantChar(text.text, variant);
|
|
9583
9635
|
}
|
|
9584
|
-
node = new
|
|
9636
|
+
node = new MathNode("mi", [text]);
|
|
9585
9637
|
if (text.text === origText && latinRegEx.test(origText)) {
|
|
9586
9638
|
node.setAttribute("mathvariant", "italic");
|
|
9587
9639
|
}
|
|
@@ -9624,11 +9676,11 @@ var temml = (function () {
|
|
|
9624
9676
|
// Firefox does not render a space in a <mtext> </mtext>. So write a no-break space.
|
|
9625
9677
|
// TODO: If Firefox fixes that bug, uncomment the next line and write ch into the node.
|
|
9626
9678
|
//const ch = (regularSpace[group.text].className === "nobreak") ? "\u00a0" : " "
|
|
9627
|
-
node = new
|
|
9679
|
+
node = new MathNode("mtext", [new TextNode("\u00a0")]);
|
|
9628
9680
|
} else if (Object.prototype.hasOwnProperty.call(cssSpace, group.text)) {
|
|
9629
9681
|
// MathML 3.0 calls for nobreak to occur in an <mo>, not an <mtext>
|
|
9630
9682
|
// Ref: https://www.w3.org/Math/draft-spec/mathml.html#chapter3_presm.lbattrs
|
|
9631
|
-
node = new
|
|
9683
|
+
node = new MathNode("mo");
|
|
9632
9684
|
if (group.text === "\\nobreak") {
|
|
9633
9685
|
node.setAttribute("linebreak", "nobreak");
|
|
9634
9686
|
}
|
|
@@ -9743,10 +9795,10 @@ var temml = (function () {
|
|
|
9743
9795
|
},
|
|
9744
9796
|
mathmlBuilder(group, style) {
|
|
9745
9797
|
// Use a math table to create vertically centered content.
|
|
9746
|
-
const mtd = new
|
|
9798
|
+
const mtd = new MathNode("mtd", [buildGroup$1(group.body, style)]);
|
|
9747
9799
|
mtd.style.padding = "0";
|
|
9748
|
-
const mtr = new
|
|
9749
|
-
return new
|
|
9800
|
+
const mtr = new MathNode("mtr", [mtd]);
|
|
9801
|
+
return new MathNode("mtable", [mtr])
|
|
9750
9802
|
}
|
|
9751
9803
|
});
|
|
9752
9804
|
|
|
@@ -9765,8 +9817,8 @@ var temml = (function () {
|
|
|
9765
9817
|
throw new ParseError("\\verb ended by end of line instead of matching delimiter");
|
|
9766
9818
|
},
|
|
9767
9819
|
mathmlBuilder(group, style) {
|
|
9768
|
-
const text = new
|
|
9769
|
-
const node = new
|
|
9820
|
+
const text = new TextNode(makeVerb(group));
|
|
9821
|
+
const node = new MathNode("mtext", [text]);
|
|
9770
9822
|
node.setAttribute("mathvariant", "monospace");
|
|
9771
9823
|
return node;
|
|
9772
9824
|
}
|
|
@@ -12098,7 +12150,7 @@ var temml = (function () {
|
|
|
12098
12150
|
* https://mit-license.org/
|
|
12099
12151
|
*/
|
|
12100
12152
|
|
|
12101
|
-
const version = "0.
|
|
12153
|
+
const version = "0.12.02";
|
|
12102
12154
|
|
|
12103
12155
|
function postProcess(block) {
|
|
12104
12156
|
const labelMap = {};
|