temml 0.10.2 → 0.10.4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +3 -4
- package/dist/Temml-Asana.css +17 -1
- package/dist/Temml-Latin-Modern.css +17 -5
- package/dist/Temml-Libertinus.css +17 -5
- package/dist/Temml-Local.css +16 -0
- package/dist/Temml-STIX2.css +16 -0
- package/dist/temml.cjs +56 -36
- package/dist/temml.js +56 -36
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +56 -36
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +8 -2
- package/src/Lexer.js +2 -8
- package/src/Parser.js +0 -11
- package/src/Settings.js +1 -1
- package/src/buildMathML.js +47 -12
- package/src/functions/symbolsOrd.js +1 -1
- package/src/linebreaking.js +3 -1
- package/src/postProcess.js +1 -1
package/README.md
CHANGED
@@ -7,11 +7,10 @@
|
|
7
7
|
| KaTeX | 280 KB |
|
8
8
|
| TeXZilla | 168 KB |
|
9
9
|
|
10
|
-
As a futher advantage, Temml can use local system fonts. The minimum Temml installation serves a font file that is only 12kb.
|
10
|
+
As a futher advantage, Temml can use local system fonts. The minimum Temml installation serves a font file that is only 12kb. Sadly, Chromium has some rendering bugs when using system fonts. It
|
11
|
+
work better with the Latin Modern font, a 380 KB file.
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
Temml’s coverage of LaTeX functions is as good as MathJax, slightly better than KaTeX 0.13.0 and substantially better than TeXZilla. See a [detailed coverage comparison](https://temml.org/docs/en/comparison.html).
|
13
|
+
Temml’s coverage of LaTeX functions is as good as MathJax, slightly better than KaTeX 0.16.0 and substantially better than TeXZilla. See a [detailed coverage comparison](https://temml.org/docs/en/comparison.html).
|
15
14
|
|
16
15
|
Temml's test suite includes many rendered examples, including the Temml [supported functions page](https://temml.org/docs/en/supported.html) and tests from [Mozilla](https://temml.org/tests/mozilla-tests.html), [Wikipedia](https://temml.org/tests/wiki-tests.html), [mhchem](https://temml.org/tests/mhchem-tests.html), and [LaTeXML](https://temml.org/tests/LaTeXML-tests.html).
|
17
16
|
|
package/dist/Temml-Asana.css
CHANGED
@@ -35,7 +35,7 @@ mtext {
|
|
35
35
|
}
|
36
36
|
|
37
37
|
math {
|
38
|
-
font-family: Asana Math;
|
38
|
+
font-family: Asana Math, math;
|
39
39
|
}
|
40
40
|
|
41
41
|
*.mathcal,
|
@@ -43,6 +43,22 @@ mo.tml-prime {
|
|
43
43
|
font-feature-settings: 'salt';
|
44
44
|
}
|
45
45
|
|
46
|
+
/* flex-wrap for line-breaking in Chromium */
|
47
|
+
math {
|
48
|
+
display: inline-flex;
|
49
|
+
flex-wrap: wrap;
|
50
|
+
align-items: baseline;
|
51
|
+
}
|
52
|
+
math > mrow {
|
53
|
+
padding: 0.5ex 0ex;
|
54
|
+
}
|
55
|
+
|
56
|
+
/* Avoid flex-wrap in Firefox */
|
57
|
+
@supports (-moz-appearance:meterbar) and (display:flex) {
|
58
|
+
math { display: inline; }
|
59
|
+
math > mrow { padding: 0 }
|
60
|
+
}
|
61
|
+
|
46
62
|
/* AMS environment auto-numbering via CSS counter. */
|
47
63
|
.tml-eqn::before {
|
48
64
|
counter-increment: tmlEqnNo;
|
@@ -40,12 +40,8 @@ math * {
|
|
40
40
|
border-color: currentColor;
|
41
41
|
}
|
42
42
|
|
43
|
-
.latin-modern math {
|
44
|
-
font-family: "Latin Modern Math", "Times New Roman", math;
|
45
|
-
}
|
46
|
-
|
47
43
|
math {
|
48
|
-
font-family: Latin Modern Math;
|
44
|
+
font-family: "Latin Modern Math", "Times New Roman", math;
|
49
45
|
}
|
50
46
|
|
51
47
|
*.mathscr {
|
@@ -56,6 +52,22 @@ mo.tml-prime {
|
|
56
52
|
font-family: Temml;
|
57
53
|
}
|
58
54
|
|
55
|
+
/* flex-wrap for line-breaking in Chromium */
|
56
|
+
math {
|
57
|
+
display: inline-flex;
|
58
|
+
flex-wrap: wrap;
|
59
|
+
align-items: baseline;
|
60
|
+
}
|
61
|
+
math > mrow {
|
62
|
+
padding: 0.5ex 0ex;
|
63
|
+
}
|
64
|
+
|
65
|
+
/* Avoid flex-wrap in Firefox */
|
66
|
+
@supports (-moz-appearance:meterbar) and (display:flex) {
|
67
|
+
math { display: inline; }
|
68
|
+
math > mrow { padding: 0 }
|
69
|
+
}
|
70
|
+
|
59
71
|
/* AMS environment auto-numbering via CSS counter. */
|
60
72
|
.tml-eqn::before {
|
61
73
|
counter-increment: tmlEqnNo;
|
@@ -38,12 +38,8 @@ math * {
|
|
38
38
|
border-color: currentColor;
|
39
39
|
}
|
40
40
|
|
41
|
-
.libertinus math {
|
42
|
-
font-family: "Libertinus Math", "Times New Roman", math;
|
43
|
-
}
|
44
|
-
|
45
41
|
math {
|
46
|
-
font-family: Libertinus Math;
|
42
|
+
font-family: Libertinus Math, math;
|
47
43
|
}
|
48
44
|
|
49
45
|
*.mathcal {
|
@@ -54,6 +50,22 @@ mo.tml-prime {
|
|
54
50
|
font-feature-settings: 'ssty';
|
55
51
|
}
|
56
52
|
|
53
|
+
/* flex-wrap for line-breaking in Chromium */
|
54
|
+
math {
|
55
|
+
display: inline-flex;
|
56
|
+
flex-wrap: wrap;
|
57
|
+
align-items: baseline;
|
58
|
+
}
|
59
|
+
math > mrow {
|
60
|
+
padding: 0.5ex 0ex;
|
61
|
+
}
|
62
|
+
|
63
|
+
/* Avoid flex-wrap in Firefox */
|
64
|
+
@supports (-moz-appearance:meterbar) and (display:flex) {
|
65
|
+
math { display: inline; }
|
66
|
+
math > mrow { padding: 0 }
|
67
|
+
}
|
68
|
+
|
57
69
|
/* AMS environment auto-numbering via CSS counter. */
|
58
70
|
.tml-eqn::before {
|
59
71
|
counter-increment: tmlEqnNo;
|
package/dist/Temml-Local.css
CHANGED
@@ -36,6 +36,22 @@ mo.tml-prime {
|
|
36
36
|
font-family: Temml;
|
37
37
|
}
|
38
38
|
|
39
|
+
/* flex-wrap for line-breaking in Chromium */
|
40
|
+
math {
|
41
|
+
display: inline-flex;
|
42
|
+
flex-wrap: wrap;
|
43
|
+
align-items: baseline;
|
44
|
+
}
|
45
|
+
math > mrow {
|
46
|
+
padding: 0.5ex 0ex;
|
47
|
+
}
|
48
|
+
|
49
|
+
/* Avoid flex-wrap in Firefox */
|
50
|
+
@supports (-moz-appearance:meterbar) and (display:flex) {
|
51
|
+
math { display: inline; }
|
52
|
+
math > mrow { padding: 0 }
|
53
|
+
}
|
54
|
+
|
39
55
|
/* AMS environment auto-numbering via CSS counter. */
|
40
56
|
.tml-eqn::before {
|
41
57
|
counter-increment: tmlEqnNo;
|
package/dist/Temml-STIX2.css
CHANGED
@@ -44,6 +44,22 @@ mo.tml-prime {
|
|
44
44
|
font-feature-settings: 'ss04';
|
45
45
|
}
|
46
46
|
|
47
|
+
/* flex-wrap for line-breaking in Chromium */
|
48
|
+
math {
|
49
|
+
display: inline-flex;
|
50
|
+
flex-wrap: wrap;
|
51
|
+
align-items: baseline;
|
52
|
+
}
|
53
|
+
math > mrow {
|
54
|
+
padding: 0.5ex 0ex;
|
55
|
+
}
|
56
|
+
|
57
|
+
/* Avoid flex-wrap in Firefox */
|
58
|
+
@supports (-moz-appearance:meterbar) and (display:flex) {
|
59
|
+
math { display: inline; }
|
60
|
+
math > mrow { padding: 0 }
|
61
|
+
}
|
62
|
+
|
47
63
|
/* AMS environment auto-numbering via CSS counter. */
|
48
64
|
.tml-eqn::before {
|
49
65
|
counter-increment: tmlEqnNo;
|
package/dist/temml.cjs
CHANGED
@@ -190,7 +190,7 @@ class Settings {
|
|
190
190
|
this.leqno = utils.deflt(options.leqno, false); // boolean
|
191
191
|
this.errorColor = utils.deflt(options.errorColor, "#b22222"); // string
|
192
192
|
this.macros = options.macros || {};
|
193
|
-
this.wrap = utils.deflt(options.wrap, "
|
193
|
+
this.wrap = utils.deflt(options.wrap, "tex"); // "tex" | "="
|
194
194
|
this.xml = utils.deflt(options.xml, false); // boolean
|
195
195
|
this.colorIsTextColor = utils.deflt(options.colorIsTextColor, false); // booelean
|
196
196
|
this.strict = utils.deflt(options.strict, false); // boolean
|
@@ -1749,10 +1749,12 @@ for (let i = 0; i < 10; i++) {
|
|
1749
1749
|
* Then the top level of a <math> element can be occupied by <mrow> elements, and the browser
|
1750
1750
|
* will break after a <mrow> if the expression extends beyond the container limit.
|
1751
1751
|
*
|
1752
|
-
*
|
1752
|
+
* The default is for soft line breaks after each top-level binary or
|
1753
1753
|
* relational operator, per TeXbook p. 173. So we gather the expression into <mrow>s so that
|
1754
1754
|
* each <mrow> ends in a binary or relational operator.
|
1755
1755
|
*
|
1756
|
+
* An option is for soft line breaks before an "=" sign. That changes the <mrow>s.
|
1757
|
+
*
|
1756
1758
|
* Soft line breaks will not work in Chromium and Safari, only Firefox.
|
1757
1759
|
*
|
1758
1760
|
* Hopefully browsers will someday do their own linebreaking and we will be able to delete
|
@@ -1964,6 +1966,48 @@ const consolidateText = mrow => {
|
|
1964
1966
|
return mtext
|
1965
1967
|
};
|
1966
1968
|
|
1969
|
+
const numberRegEx$1 = /^[0-9]$/;
|
1970
|
+
const isCommaOrDot = node => {
|
1971
|
+
return (node.type === "atom" && node.text === ",") ||
|
1972
|
+
(node.type === "textord" && node.text === ".")
|
1973
|
+
};
|
1974
|
+
const consolidateNumbers = expression => {
|
1975
|
+
// Consolidate adjacent numbers. We want to return <mn>1,506.3</mn>,
|
1976
|
+
// not <mn>1</mn><mo>,</mo><mn>5</mn><mn>0</mn><mn>6</mn><mi>.</mi><mn>3</mn>
|
1977
|
+
if (expression.length < 2) { return }
|
1978
|
+
const nums = [];
|
1979
|
+
let inNum = false;
|
1980
|
+
// Find adjacent numerals
|
1981
|
+
for (let i = 0; i < expression.length; i++) {
|
1982
|
+
const node = expression[i];
|
1983
|
+
if (node.type === "textord" && numberRegEx$1.test(node.text)) {
|
1984
|
+
if (!inNum) { nums.push({ start: i }); }
|
1985
|
+
inNum = true;
|
1986
|
+
} else {
|
1987
|
+
if (inNum) { nums[nums.length - 1].end = i - 1; }
|
1988
|
+
inNum = false;
|
1989
|
+
}
|
1990
|
+
}
|
1991
|
+
if (inNum) { nums[nums.length - 1].end = expression.length - 1; }
|
1992
|
+
|
1993
|
+
// Determine if numeral groups are separated by a comma or dot.
|
1994
|
+
for (let i = nums.length - 1; i > 0; i--) {
|
1995
|
+
if (nums[i - 1].end === nums[i].start - 2 && isCommaOrDot(expression[nums[i].start - 1])) {
|
1996
|
+
// Merge the two groups.
|
1997
|
+
nums[i - 1].end = nums[i].end;
|
1998
|
+
nums.splice(i, 1);
|
1999
|
+
}
|
2000
|
+
}
|
2001
|
+
|
2002
|
+
// Consolidate the number nodes
|
2003
|
+
for (let i = nums.length - 1; i >= 0; i--) {
|
2004
|
+
for (let j = nums[i].start + 1; j <= nums[i].end; j++) {
|
2005
|
+
expression[nums[i].start].text += expression[j].text;
|
2006
|
+
}
|
2007
|
+
expression.splice(nums[i].start + 1, nums[i].end - nums[i].start);
|
2008
|
+
}
|
2009
|
+
};
|
2010
|
+
|
1967
2011
|
/**
|
1968
2012
|
* Wrap the given array of nodes in an <mrow> node if needed, i.e.,
|
1969
2013
|
* unless the array has length 1. Always returns a single node.
|
@@ -1999,6 +2043,8 @@ const buildExpression = function(expression, style, isOrdgroup) {
|
|
1999
2043
|
return [group];
|
2000
2044
|
}
|
2001
2045
|
|
2046
|
+
consolidateNumbers(expression);
|
2047
|
+
|
2002
2048
|
const groups = [];
|
2003
2049
|
for (let i = 0; i < expression.length; i++) {
|
2004
2050
|
const group = buildGroup$1(expression[i], style);
|
@@ -2098,18 +2144,6 @@ function buildMathML(tree, texExpression, style, settings) {
|
|
2098
2144
|
wrapper = new mathMLTree.MathNode("semantics", [wrapper, annotation]);
|
2099
2145
|
}
|
2100
2146
|
|
2101
|
-
if (wrap !== "none" && wrapper.children.length > 1) {
|
2102
|
-
const maths = [];
|
2103
|
-
for (let i = 0; i < wrapper.children.length; i++) {
|
2104
|
-
const math = new mathMLTree.MathNode("math", [wrapper.children[i]]);
|
2105
|
-
if (settings.xml) {
|
2106
|
-
math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
|
2107
|
-
}
|
2108
|
-
maths.push(math);
|
2109
|
-
}
|
2110
|
-
return mathMLTree.newDocumentFragment(maths)
|
2111
|
-
}
|
2112
|
-
|
2113
2147
|
const math = new mathMLTree.MathNode("math", [wrapper]);
|
2114
2148
|
|
2115
2149
|
if (settings.xml) {
|
@@ -2117,6 +2151,9 @@ function buildMathML(tree, texExpression, style, settings) {
|
|
2117
2151
|
}
|
2118
2152
|
if (settings.displayMode) {
|
2119
2153
|
math.setAttribute("display", "block");
|
2154
|
+
math.style.display = math.children.length === 1 && math.children[0].type === "mtable"
|
2155
|
+
? "inline"
|
2156
|
+
: "inline-block";
|
2120
2157
|
}
|
2121
2158
|
return math;
|
2122
2159
|
}
|
@@ -7650,7 +7687,7 @@ const smallCaps = Object.freeze({
|
|
7650
7687
|
// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in
|
7651
7688
|
// src/symbols.js.
|
7652
7689
|
|
7653
|
-
const numberRegEx
|
7690
|
+
const numberRegEx = /^\d(?:[\d,.]*\d)?$/;
|
7654
7691
|
const latinRegEx = /[A-Ba-z]/;
|
7655
7692
|
|
7656
7693
|
const italicNumber = (text, variant, tag) => {
|
@@ -7704,7 +7741,7 @@ defineFunctionBuilders({
|
|
7704
7741
|
const variant = getVariant(group, style) || "normal";
|
7705
7742
|
|
7706
7743
|
let node;
|
7707
|
-
if (numberRegEx
|
7744
|
+
if (numberRegEx.test(group.text)) {
|
7708
7745
|
const tag = group.mode === "text" ? "mtext" : "mn";
|
7709
7746
|
if (variant === "italic" || variant === "bold-italic") {
|
7710
7747
|
return italicNumber(text, variant, tag)
|
@@ -8017,8 +8054,7 @@ const combiningDiacriticalMarksEndRegex = new RegExp(`${combiningDiacriticalMark
|
|
8017
8054
|
const tokenRegexString =
|
8018
8055
|
`(${spaceRegexString}+)|` + // whitespace
|
8019
8056
|
`${controlSpaceRegexString}|` + // whitespace
|
8020
|
-
"(
|
8021
|
-
"|[!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + // single codepoint
|
8057
|
+
"([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + // single codepoint
|
8022
8058
|
`${combiningDiacriticalMarkString}*` + // ...plus accents
|
8023
8059
|
"|[\uD800-\uDBFF][\uDC00-\uDFFF]" + // surrogate pair
|
8024
8060
|
`${combiningDiacriticalMarkString}*` + // ...plus accents
|
@@ -8033,12 +8069,7 @@ class Lexer {
|
|
8033
8069
|
// Separate accents from characters
|
8034
8070
|
this.input = input;
|
8035
8071
|
this.settings = settings;
|
8036
|
-
this.tokenRegex = new RegExp(
|
8037
|
-
// Strict Temml, like TeX, lexes one numeral at a time.
|
8038
|
-
// Default Temml lexes contiguous numerals into a single <mn> element.
|
8039
|
-
tokenRegexString.replace("number|", settings.strict ? "" : "\\d(?:[\\d,.]*\\d)?|"),
|
8040
|
-
"g"
|
8041
|
-
);
|
8072
|
+
this.tokenRegex = new RegExp(tokenRegexString, 'g');
|
8042
8073
|
// Category codes. The lexer only supports comment characters (14) for now.
|
8043
8074
|
// MacroExpander additionally distinguishes active (13).
|
8044
8075
|
this.catcodes = {
|
@@ -11806,8 +11837,6 @@ var unicodeSymbols = {
|
|
11806
11837
|
|
11807
11838
|
/* eslint no-constant-condition:0 */
|
11808
11839
|
|
11809
|
-
const numberRegEx = /^\d(?:[\d,.]*\d)?$/; // Keep in sync with numberRegEx in symbolsOrd.js
|
11810
|
-
|
11811
11840
|
/**
|
11812
11841
|
* This file contains the parser used to parse out a TeX expression from the
|
11813
11842
|
* input. Since TeX isn't context-free, standard parsers don't work particularly
|
@@ -12729,15 +12758,6 @@ class Parser {
|
|
12729
12758
|
};
|
12730
12759
|
}
|
12731
12760
|
symbol = s;
|
12732
|
-
} else if (!this.strict && numberRegEx.test(text)) {
|
12733
|
-
// A number. Wrap in a <mn> if in math mode; <mtext> otherwise.
|
12734
|
-
this.consume();
|
12735
|
-
return {
|
12736
|
-
type: "textord",
|
12737
|
-
mode: this.mode,
|
12738
|
-
loc: SourceLocation.range(nucleus),
|
12739
|
-
text
|
12740
|
-
}
|
12741
12761
|
} else if (text.charCodeAt(0) >= 0x80) {
|
12742
12762
|
// no symbol for e.g. ^
|
12743
12763
|
if (this.settings.strict) {
|
@@ -12977,7 +12997,7 @@ class Style {
|
|
12977
12997
|
* https://mit-license.org/
|
12978
12998
|
*/
|
12979
12999
|
|
12980
|
-
const version = "0.10.
|
13000
|
+
const version = "0.10.4";
|
12981
13001
|
|
12982
13002
|
function postProcess(block) {
|
12983
13003
|
const labelMap = {};
|
package/dist/temml.js
CHANGED
@@ -191,7 +191,7 @@ var temml = (function () {
|
|
191
191
|
this.leqno = utils.deflt(options.leqno, false); // boolean
|
192
192
|
this.errorColor = utils.deflt(options.errorColor, "#b22222"); // string
|
193
193
|
this.macros = options.macros || {};
|
194
|
-
this.wrap = utils.deflt(options.wrap, "
|
194
|
+
this.wrap = utils.deflt(options.wrap, "tex"); // "tex" | "="
|
195
195
|
this.xml = utils.deflt(options.xml, false); // boolean
|
196
196
|
this.colorIsTextColor = utils.deflt(options.colorIsTextColor, false); // booelean
|
197
197
|
this.strict = utils.deflt(options.strict, false); // boolean
|
@@ -1750,10 +1750,12 @@ var temml = (function () {
|
|
1750
1750
|
* Then the top level of a <math> element can be occupied by <mrow> elements, and the browser
|
1751
1751
|
* will break after a <mrow> if the expression extends beyond the container limit.
|
1752
1752
|
*
|
1753
|
-
*
|
1753
|
+
* The default is for soft line breaks after each top-level binary or
|
1754
1754
|
* relational operator, per TeXbook p. 173. So we gather the expression into <mrow>s so that
|
1755
1755
|
* each <mrow> ends in a binary or relational operator.
|
1756
1756
|
*
|
1757
|
+
* An option is for soft line breaks before an "=" sign. That changes the <mrow>s.
|
1758
|
+
*
|
1757
1759
|
* Soft line breaks will not work in Chromium and Safari, only Firefox.
|
1758
1760
|
*
|
1759
1761
|
* Hopefully browsers will someday do their own linebreaking and we will be able to delete
|
@@ -1965,6 +1967,48 @@ var temml = (function () {
|
|
1965
1967
|
return mtext
|
1966
1968
|
};
|
1967
1969
|
|
1970
|
+
const numberRegEx$1 = /^[0-9]$/;
|
1971
|
+
const isCommaOrDot = node => {
|
1972
|
+
return (node.type === "atom" && node.text === ",") ||
|
1973
|
+
(node.type === "textord" && node.text === ".")
|
1974
|
+
};
|
1975
|
+
const consolidateNumbers = expression => {
|
1976
|
+
// Consolidate adjacent numbers. We want to return <mn>1,506.3</mn>,
|
1977
|
+
// not <mn>1</mn><mo>,</mo><mn>5</mn><mn>0</mn><mn>6</mn><mi>.</mi><mn>3</mn>
|
1978
|
+
if (expression.length < 2) { return }
|
1979
|
+
const nums = [];
|
1980
|
+
let inNum = false;
|
1981
|
+
// Find adjacent numerals
|
1982
|
+
for (let i = 0; i < expression.length; i++) {
|
1983
|
+
const node = expression[i];
|
1984
|
+
if (node.type === "textord" && numberRegEx$1.test(node.text)) {
|
1985
|
+
if (!inNum) { nums.push({ start: i }); }
|
1986
|
+
inNum = true;
|
1987
|
+
} else {
|
1988
|
+
if (inNum) { nums[nums.length - 1].end = i - 1; }
|
1989
|
+
inNum = false;
|
1990
|
+
}
|
1991
|
+
}
|
1992
|
+
if (inNum) { nums[nums.length - 1].end = expression.length - 1; }
|
1993
|
+
|
1994
|
+
// Determine if numeral groups are separated by a comma or dot.
|
1995
|
+
for (let i = nums.length - 1; i > 0; i--) {
|
1996
|
+
if (nums[i - 1].end === nums[i].start - 2 && isCommaOrDot(expression[nums[i].start - 1])) {
|
1997
|
+
// Merge the two groups.
|
1998
|
+
nums[i - 1].end = nums[i].end;
|
1999
|
+
nums.splice(i, 1);
|
2000
|
+
}
|
2001
|
+
}
|
2002
|
+
|
2003
|
+
// Consolidate the number nodes
|
2004
|
+
for (let i = nums.length - 1; i >= 0; i--) {
|
2005
|
+
for (let j = nums[i].start + 1; j <= nums[i].end; j++) {
|
2006
|
+
expression[nums[i].start].text += expression[j].text;
|
2007
|
+
}
|
2008
|
+
expression.splice(nums[i].start + 1, nums[i].end - nums[i].start);
|
2009
|
+
}
|
2010
|
+
};
|
2011
|
+
|
1968
2012
|
/**
|
1969
2013
|
* Wrap the given array of nodes in an <mrow> node if needed, i.e.,
|
1970
2014
|
* unless the array has length 1. Always returns a single node.
|
@@ -2000,6 +2044,8 @@ var temml = (function () {
|
|
2000
2044
|
return [group];
|
2001
2045
|
}
|
2002
2046
|
|
2047
|
+
consolidateNumbers(expression);
|
2048
|
+
|
2003
2049
|
const groups = [];
|
2004
2050
|
for (let i = 0; i < expression.length; i++) {
|
2005
2051
|
const group = buildGroup$1(expression[i], style);
|
@@ -2099,18 +2145,6 @@ var temml = (function () {
|
|
2099
2145
|
wrapper = new mathMLTree.MathNode("semantics", [wrapper, annotation]);
|
2100
2146
|
}
|
2101
2147
|
|
2102
|
-
if (wrap !== "none" && wrapper.children.length > 1) {
|
2103
|
-
const maths = [];
|
2104
|
-
for (let i = 0; i < wrapper.children.length; i++) {
|
2105
|
-
const math = new mathMLTree.MathNode("math", [wrapper.children[i]]);
|
2106
|
-
if (settings.xml) {
|
2107
|
-
math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
|
2108
|
-
}
|
2109
|
-
maths.push(math);
|
2110
|
-
}
|
2111
|
-
return mathMLTree.newDocumentFragment(maths)
|
2112
|
-
}
|
2113
|
-
|
2114
2148
|
const math = new mathMLTree.MathNode("math", [wrapper]);
|
2115
2149
|
|
2116
2150
|
if (settings.xml) {
|
@@ -2118,6 +2152,9 @@ var temml = (function () {
|
|
2118
2152
|
}
|
2119
2153
|
if (settings.displayMode) {
|
2120
2154
|
math.setAttribute("display", "block");
|
2155
|
+
math.style.display = math.children.length === 1 && math.children[0].type === "mtable"
|
2156
|
+
? "inline"
|
2157
|
+
: "inline-block";
|
2121
2158
|
}
|
2122
2159
|
return math;
|
2123
2160
|
}
|
@@ -7651,7 +7688,7 @@ var temml = (function () {
|
|
7651
7688
|
// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in
|
7652
7689
|
// src/symbols.js.
|
7653
7690
|
|
7654
|
-
const numberRegEx
|
7691
|
+
const numberRegEx = /^\d(?:[\d,.]*\d)?$/;
|
7655
7692
|
const latinRegEx = /[A-Ba-z]/;
|
7656
7693
|
|
7657
7694
|
const italicNumber = (text, variant, tag) => {
|
@@ -7705,7 +7742,7 @@ var temml = (function () {
|
|
7705
7742
|
const variant = getVariant(group, style) || "normal";
|
7706
7743
|
|
7707
7744
|
let node;
|
7708
|
-
if (numberRegEx
|
7745
|
+
if (numberRegEx.test(group.text)) {
|
7709
7746
|
const tag = group.mode === "text" ? "mtext" : "mn";
|
7710
7747
|
if (variant === "italic" || variant === "bold-italic") {
|
7711
7748
|
return italicNumber(text, variant, tag)
|
@@ -8018,8 +8055,7 @@ var temml = (function () {
|
|
8018
8055
|
const tokenRegexString =
|
8019
8056
|
`(${spaceRegexString}+)|` + // whitespace
|
8020
8057
|
`${controlSpaceRegexString}|` + // whitespace
|
8021
|
-
"(
|
8022
|
-
"|[!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + // single codepoint
|
8058
|
+
"([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + // single codepoint
|
8023
8059
|
`${combiningDiacriticalMarkString}*` + // ...plus accents
|
8024
8060
|
"|[\uD800-\uDBFF][\uDC00-\uDFFF]" + // surrogate pair
|
8025
8061
|
`${combiningDiacriticalMarkString}*` + // ...plus accents
|
@@ -8034,12 +8070,7 @@ var temml = (function () {
|
|
8034
8070
|
// Separate accents from characters
|
8035
8071
|
this.input = input;
|
8036
8072
|
this.settings = settings;
|
8037
|
-
this.tokenRegex = new RegExp(
|
8038
|
-
// Strict Temml, like TeX, lexes one numeral at a time.
|
8039
|
-
// Default Temml lexes contiguous numerals into a single <mn> element.
|
8040
|
-
tokenRegexString.replace("number|", settings.strict ? "" : "\\d(?:[\\d,.]*\\d)?|"),
|
8041
|
-
"g"
|
8042
|
-
);
|
8073
|
+
this.tokenRegex = new RegExp(tokenRegexString, 'g');
|
8043
8074
|
// Category codes. The lexer only supports comment characters (14) for now.
|
8044
8075
|
// MacroExpander additionally distinguishes active (13).
|
8045
8076
|
this.catcodes = {
|
@@ -9907,8 +9938,6 @@ var temml = (function () {
|
|
9907
9938
|
|
9908
9939
|
/* eslint no-constant-condition:0 */
|
9909
9940
|
|
9910
|
-
const numberRegEx = /^\d(?:[\d,.]*\d)?$/; // Keep in sync with numberRegEx in symbolsOrd.js
|
9911
|
-
|
9912
9941
|
/**
|
9913
9942
|
* This file contains the parser used to parse out a TeX expression from the
|
9914
9943
|
* input. Since TeX isn't context-free, standard parsers don't work particularly
|
@@ -10830,15 +10859,6 @@ var temml = (function () {
|
|
10830
10859
|
};
|
10831
10860
|
}
|
10832
10861
|
symbol = s;
|
10833
|
-
} else if (!this.strict && numberRegEx.test(text)) {
|
10834
|
-
// A number. Wrap in a <mn> if in math mode; <mtext> otherwise.
|
10835
|
-
this.consume();
|
10836
|
-
return {
|
10837
|
-
type: "textord",
|
10838
|
-
mode: this.mode,
|
10839
|
-
loc: SourceLocation.range(nucleus),
|
10840
|
-
text
|
10841
|
-
}
|
10842
10862
|
} else if (text.charCodeAt(0) >= 0x80) {
|
10843
10863
|
// no symbol for e.g. ^
|
10844
10864
|
if (this.settings.strict) {
|
@@ -11078,7 +11098,7 @@ var temml = (function () {
|
|
11078
11098
|
* https://mit-license.org/
|
11079
11099
|
*/
|
11080
11100
|
|
11081
|
-
const version = "0.10.
|
11101
|
+
const version = "0.10.4";
|
11082
11102
|
|
11083
11103
|
function postProcess(block) {
|
11084
11104
|
const labelMap = {};
|