temml 0.10.19 → 0.10.20
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/dist/Temml-Asana.css +33 -0
- package/dist/Temml-Latin-Modern.css +33 -0
- package/dist/Temml-Libertinus.css +33 -0
- package/dist/Temml-Local.css +33 -0
- package/dist/Temml-STIX2.css +33 -0
- package/dist/temml.cjs +46 -44
- package/dist/temml.js +46 -44
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +46 -44
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +1 -1
- package/src/Parser.js +8 -3
- package/src/buildMathML.js +10 -8
- package/src/environments/array.js +6 -3
- package/src/environments/cd.js +2 -1
- package/src/functions/enclose.js +5 -24
- package/src/functions/font.js +1 -1
- package/src/functions/not.js +2 -2
- package/src/functions/op.js +10 -0
- package/src/functions/ordgroup.js +1 -1
- package/src/postProcess.js +1 -1
- package/src/svg.js +0 -110
package/dist/temml.mjs
CHANGED
@@ -2070,20 +2070,22 @@ const consolidateNumbers = expression => {
|
|
2070
2070
|
* Wrap the given array of nodes in an <mrow> node if needed, i.e.,
|
2071
2071
|
* unless the array has length 1. Always returns a single node.
|
2072
2072
|
*/
|
2073
|
-
const makeRow = function(body) {
|
2073
|
+
const makeRow = function(body, semisimple = false) {
|
2074
2074
|
if (body.length === 1 && !(body[0] instanceof DocumentFragment)) {
|
2075
2075
|
return body[0];
|
2076
|
-
} else {
|
2076
|
+
} else if (!semisimple) {
|
2077
2077
|
// Suppress spacing on <mo> nodes at both ends of the row.
|
2078
2078
|
if (body[0] instanceof MathNode && body[0].type === "mo" && !body[0].attributes.fence) {
|
2079
2079
|
body[0].attributes.lspace = "0em";
|
2080
|
+
body[0].attributes.rspace = "0em";
|
2080
2081
|
}
|
2081
2082
|
const end = body.length - 1;
|
2082
2083
|
if (body[end] instanceof MathNode && body[end].type === "mo" && !body[end].attributes.fence) {
|
2084
|
+
body[end].attributes.lspace = "0em";
|
2083
2085
|
body[end].attributes.rspace = "0em";
|
2084
2086
|
}
|
2085
|
-
return new mathMLTree.MathNode("mrow", body);
|
2086
2087
|
}
|
2088
|
+
return new mathMLTree.MathNode("mrow", body);
|
2087
2089
|
};
|
2088
2090
|
|
2089
2091
|
const isRel = item => {
|
@@ -2097,10 +2099,10 @@ const isRel = item => {
|
|
2097
2099
|
* (1) Suppress spacing when an author wraps an operator w/braces, as in {=}.
|
2098
2100
|
* (2) Suppress spacing between two adjacent relations.
|
2099
2101
|
*/
|
2100
|
-
const buildExpression = function(expression, style,
|
2101
|
-
if (expression.length === 1) {
|
2102
|
+
const buildExpression = function(expression, style, semisimple = false) {
|
2103
|
+
if (!semisimple && expression.length === 1) {
|
2102
2104
|
const group = buildGroup$1(expression[0], style);
|
2103
|
-
if (
|
2105
|
+
if (group instanceof MathNode && group.type === "mo") {
|
2104
2106
|
// When TeX writers want to suppress spacing on an operator,
|
2105
2107
|
// they often put the operator by itself inside braces.
|
2106
2108
|
group.setAttribute("lspace", "0em");
|
@@ -2130,8 +2132,8 @@ const buildExpression = function(expression, style, isOrdgroup) {
|
|
2130
2132
|
* Equivalent to buildExpression, but wraps the elements in an <mrow>
|
2131
2133
|
* if there's more than one. Returns a single node instead of an array.
|
2132
2134
|
*/
|
2133
|
-
const buildExpressionRow = function(expression, style,
|
2134
|
-
return makeRow(buildExpression(expression, style,
|
2135
|
+
const buildExpressionRow = function(expression, style, semisimple = false) {
|
2136
|
+
return makeRow(buildExpression(expression, style, semisimple), semisimple);
|
2135
2137
|
};
|
2136
2138
|
|
2137
2139
|
/**
|
@@ -2816,7 +2818,8 @@ function cdArrow(arrowChar, labels, parser) {
|
|
2816
2818
|
const arrowGroup = {
|
2817
2819
|
type: "ordgroup",
|
2818
2820
|
mode: "math",
|
2819
|
-
body: [leftLabel, sizedArrow, rightLabel]
|
2821
|
+
body: [leftLabel, sizedArrow, rightLabel],
|
2822
|
+
semisimple: true
|
2820
2823
|
};
|
2821
2824
|
return parser.callFunction("\\\\cdparent", [arrowGroup], []);
|
2822
2825
|
}
|
@@ -3938,20 +3941,12 @@ const mathmlBuilder$8 = (group, style) => {
|
|
3938
3941
|
node.style.borderBottom = "0.065em solid";
|
3939
3942
|
break
|
3940
3943
|
case "\\cancel":
|
3941
|
-
|
3942
|
-
|
3943
|
-
|
3944
|
-
rgba(0,0,0,1) 50%,
|
3945
|
-
rgba(0,0,0,0) calc(50% + 0.06em),
|
3946
|
-
rgba(0,0,0,0) 100%);`;
|
3944
|
+
// We can't use an inline background-gradient. It does not work client-side.
|
3945
|
+
// So set a class and put the rule in the external CSS file.
|
3946
|
+
node.classes.push("tml-cancel");
|
3947
3947
|
break
|
3948
3948
|
case "\\bcancel":
|
3949
|
-
node.
|
3950
|
-
rgba(0,0,0,0) 0%,
|
3951
|
-
rgba(0,0,0,0) calc(50% - 0.06em),
|
3952
|
-
rgba(0,0,0,1) 50%,
|
3953
|
-
rgba(0,0,0,0) calc(50% + 0.06em),
|
3954
|
-
rgba(0,0,0,0) 100%);`;
|
3949
|
+
node.classes.push("tml-bcancel");
|
3955
3950
|
break
|
3956
3951
|
/*
|
3957
3952
|
case "\\longdiv":
|
@@ -3998,18 +3993,7 @@ rgba(0,0,0,0) 100%);`;
|
|
3998
3993
|
break
|
3999
3994
|
}
|
4000
3995
|
case "\\xcancel":
|
4001
|
-
node.
|
4002
|
-
rgba(0,0,0,0) 0%,
|
4003
|
-
rgba(0,0,0,0) calc(50% - 0.06em),
|
4004
|
-
rgba(0,0,0,1) 50%,
|
4005
|
-
rgba(0,0,0,0) calc(50% + 0.06em),
|
4006
|
-
rgba(0,0,0,0) 100%),
|
4007
|
-
linear-gradient(to top right,
|
4008
|
-
rgba(0,0,0,0) 0%,
|
4009
|
-
rgba(0,0,0,0) calc(50% - 0.06em),
|
4010
|
-
rgba(0,0,0,1) 50%,
|
4011
|
-
rgba(0,0,0,0) calc(50% + 0.06em),
|
4012
|
-
rgba(0,0,0,0) 100%);`;
|
3996
|
+
node.classes.push("tml-xcancel");
|
4013
3997
|
break
|
4014
3998
|
}
|
4015
3999
|
if (group.backgroundColor) {
|
@@ -4207,7 +4191,7 @@ const getTag = (group, style, rowNum) => {
|
|
4207
4191
|
if (tagContents) {
|
4208
4192
|
// The author has written a \tag or a \notag in this row.
|
4209
4193
|
if (tagContents.body) {
|
4210
|
-
tag = buildExpressionRow(tagContents.body, style);
|
4194
|
+
tag = buildExpressionRow(tagContents.body, style, true);
|
4211
4195
|
tag.classes = ["tml-tag"];
|
4212
4196
|
} else {
|
4213
4197
|
// \notag. Return an empty span.
|
@@ -4254,7 +4238,9 @@ function parseArray(
|
|
4254
4238
|
parser.gullet.macros.set("\\cr", "\\\\\\relax");
|
4255
4239
|
}
|
4256
4240
|
if (addEqnNum) {
|
4257
|
-
parser.gullet.macros.set("\\tag", "\\
|
4241
|
+
parser.gullet.macros.set("\\tag", "\\@ifstar\\envtag@literal\\envtag@paren");
|
4242
|
+
parser.gullet.macros.set("\\envtag@paren", "\\env@tag{{(\\text{#1})}}");
|
4243
|
+
parser.gullet.macros.set("\\envtag@literal", "\\env@tag{\\text{#1}}");
|
4258
4244
|
parser.gullet.macros.set("\\notag", "\\env@notag");
|
4259
4245
|
parser.gullet.macros.set("\\nonumber", "\\env@notag");
|
4260
4246
|
}
|
@@ -4295,7 +4281,8 @@ function parseArray(
|
|
4295
4281
|
cell = {
|
4296
4282
|
type: "ordgroup",
|
4297
4283
|
mode: parser.mode,
|
4298
|
-
body: cell
|
4284
|
+
body: cell,
|
4285
|
+
semisimple: true
|
4299
4286
|
};
|
4300
4287
|
row.push(cell);
|
4301
4288
|
const next = parser.fetch().text;
|
@@ -5128,7 +5115,7 @@ const mathmlBuilder$6 = (group, style) => {
|
|
5128
5115
|
const mathGroup = buildGroup$1(group.body, newStyle);
|
5129
5116
|
|
5130
5117
|
if (mathGroup.children.length === 0) { return mathGroup } // empty group, e.g., \mathrm{}
|
5131
|
-
if (font === "boldsymbol" && ["mo", "mpadded"].includes(mathGroup.type)) {
|
5118
|
+
if (font === "boldsymbol" && ["mo", "mpadded", "mrow"].includes(mathGroup.type)) {
|
5132
5119
|
mathGroup.style.fontWeight = "bold";
|
5133
5120
|
return mathGroup
|
5134
5121
|
}
|
@@ -6485,10 +6472,10 @@ defineFunction({
|
|
6485
6472
|
},
|
6486
6473
|
mathmlBuilder(group, style) {
|
6487
6474
|
if (group.isCharacterBox) {
|
6488
|
-
const inner = buildExpression(group.body, style);
|
6475
|
+
const inner = buildExpression(group.body, style, true);
|
6489
6476
|
return inner[0]
|
6490
6477
|
} else {
|
6491
|
-
return buildExpressionRow(group.body, style
|
6478
|
+
return buildExpressionRow(group.body, style)
|
6492
6479
|
}
|
6493
6480
|
}
|
6494
6481
|
});
|
@@ -6508,6 +6495,13 @@ const ordTypes = ["textord", "mathord", "ordgroup", "close", "leftright"];
|
|
6508
6495
|
// NOTE: Unlike most `builders`s, this one handles not only "op", but also
|
6509
6496
|
// "supsub" since some of them (like \int) can affect super/subscripting.
|
6510
6497
|
|
6498
|
+
const setSpacing = node => {
|
6499
|
+
// The user wrote a \mathop{…} function. Change spacing from default to OP spacing.
|
6500
|
+
// The most likely spacing for an OP is a thin space per TeXbook p170.
|
6501
|
+
node.attributes.lspace = "0.1667em";
|
6502
|
+
node.attributes.rspace = "0.1667em";
|
6503
|
+
};
|
6504
|
+
|
6511
6505
|
const mathmlBuilder$2 = (group, style) => {
|
6512
6506
|
let node;
|
6513
6507
|
|
@@ -6519,9 +6513,11 @@ const mathmlBuilder$2 = (group, style) => {
|
|
6519
6513
|
} else {
|
6520
6514
|
node.setAttribute("movablelimits", "false");
|
6521
6515
|
}
|
6516
|
+
if (group.fromMathOp) { setSpacing(node); }
|
6522
6517
|
} else if (group.body) {
|
6523
6518
|
// This is an operator with children. Add them.
|
6524
6519
|
node = new MathNode("mo", buildExpression(group.body, style));
|
6520
|
+
if (group.fromMathOp) { setSpacing(node); }
|
6525
6521
|
} else {
|
6526
6522
|
// This is a text operator. Add all of the characters from the operator's name.
|
6527
6523
|
node = new MathNode("mi", [new TextNode(group.name.slice(1))]);
|
@@ -6641,6 +6637,7 @@ defineFunction({
|
|
6641
6637
|
limits: true,
|
6642
6638
|
parentIsSupSub: false,
|
6643
6639
|
symbol: isSymbol,
|
6640
|
+
fromMathOp: true,
|
6644
6641
|
stack: false,
|
6645
6642
|
name: isSymbol ? arr[0].text : null,
|
6646
6643
|
body: isSymbol ? null : ordargument(body)
|
@@ -6974,7 +6971,7 @@ defineMacro("\\operatorname",
|
|
6974
6971
|
defineFunctionBuilders({
|
6975
6972
|
type: "ordgroup",
|
6976
6973
|
mathmlBuilder(group, style) {
|
6977
|
-
return buildExpressionRow(group.body, style,
|
6974
|
+
return buildExpressionRow(group.body, style, group.semisimple);
|
6978
6975
|
}
|
6979
6976
|
});
|
6980
6977
|
|
@@ -12003,6 +12000,8 @@ var unicodeSymbols = {
|
|
12003
12000
|
|
12004
12001
|
/* eslint no-constant-condition:0 */
|
12005
12002
|
|
12003
|
+
const binLeftCancellers = ["bin", "op", "open", "punct", "rel"];
|
12004
|
+
|
12006
12005
|
/**
|
12007
12006
|
* This file contains the parser used to parse out a TeX expression from the
|
12008
12007
|
* input. Since TeX isn't context-free, standard parsers don't work particularly
|
@@ -12772,8 +12771,7 @@ class Parser {
|
|
12772
12771
|
body: expression,
|
12773
12772
|
// A group formed by \begingroup...\endgroup is a semi-simple group
|
12774
12773
|
// which doesn't affect spacing in math mode, i.e., is transparent.
|
12775
|
-
// https://tex.stackexchange.com/questions/1930/
|
12776
|
-
// use-begingroup-instead-of-bgroup
|
12774
|
+
// https://tex.stackexchange.com/questions/1930/
|
12777
12775
|
semisimple: text === "\\begingroup" || undefined
|
12778
12776
|
};
|
12779
12777
|
} else {
|
@@ -12887,7 +12885,11 @@ class Parser {
|
|
12887
12885
|
// Recognize base symbol
|
12888
12886
|
let symbol;
|
12889
12887
|
if (symbols[this.mode][text]) {
|
12890
|
-
|
12888
|
+
let group = symbols[this.mode][text].group;
|
12889
|
+
if (group === "bin" && binLeftCancellers.includes(this.prevAtomType)) {
|
12890
|
+
// Change from a binary operator to a unary (prefix) operator
|
12891
|
+
group = "open";
|
12892
|
+
}
|
12891
12893
|
const loc = SourceLocation.range(nucleus);
|
12892
12894
|
let s;
|
12893
12895
|
if (Object.prototype.hasOwnProperty.call(ATOMS, group )) {
|
@@ -13157,7 +13159,7 @@ class Style {
|
|
13157
13159
|
* https://mit-license.org/
|
13158
13160
|
*/
|
13159
13161
|
|
13160
|
-
const version = "0.10.
|
13162
|
+
const version = "0.10.20";
|
13161
13163
|
|
13162
13164
|
function postProcess(block) {
|
13163
13165
|
const labelMap = {};
|
package/dist/temmlPostProcess.js
CHANGED
package/package.json
CHANGED
package/src/Parser.js
CHANGED
@@ -15,6 +15,8 @@ import { isDelimiter } from "./functions/delimsizing"
|
|
15
15
|
import unicodeAccents from /*preval*/ "./unicodeAccents";
|
16
16
|
import unicodeSymbols from /*preval*/ "./unicodeSymbols";
|
17
17
|
|
18
|
+
const binLeftCancellers = ["bin", "op", "open", "punct", "rel"];
|
19
|
+
|
18
20
|
/**
|
19
21
|
* This file contains the parser used to parse out a TeX expression from the
|
20
22
|
* input. Since TeX isn't context-free, standard parsers don't work particularly
|
@@ -784,8 +786,7 @@ export default class Parser {
|
|
784
786
|
body: expression,
|
785
787
|
// A group formed by \begingroup...\endgroup is a semi-simple group
|
786
788
|
// which doesn't affect spacing in math mode, i.e., is transparent.
|
787
|
-
// https://tex.stackexchange.com/questions/1930/
|
788
|
-
// use-begingroup-instead-of-bgroup
|
789
|
+
// https://tex.stackexchange.com/questions/1930/
|
789
790
|
semisimple: text === "\\begingroup" || undefined
|
790
791
|
};
|
791
792
|
} else {
|
@@ -899,7 +900,11 @@ export default class Parser {
|
|
899
900
|
// Recognize base symbol
|
900
901
|
let symbol;
|
901
902
|
if (symbols[this.mode][text]) {
|
902
|
-
|
903
|
+
let group = symbols[this.mode][text].group;
|
904
|
+
if (group === "bin" && binLeftCancellers.includes(this.prevAtomType)) {
|
905
|
+
// Change from a binary operator to a unary (prefix) operator
|
906
|
+
group = "open"
|
907
|
+
}
|
903
908
|
const loc = SourceLocation.range(nucleus);
|
904
909
|
let s;
|
905
910
|
if (Object.prototype.hasOwnProperty.call(ATOMS, group )) {
|
package/src/buildMathML.js
CHANGED
@@ -135,20 +135,22 @@ const consolidateNumbers = expression => {
|
|
135
135
|
* Wrap the given array of nodes in an <mrow> node if needed, i.e.,
|
136
136
|
* unless the array has length 1. Always returns a single node.
|
137
137
|
*/
|
138
|
-
export const makeRow = function(body) {
|
138
|
+
export const makeRow = function(body, semisimple = false) {
|
139
139
|
if (body.length === 1 && !(body[0] instanceof DocumentFragment)) {
|
140
140
|
return body[0];
|
141
|
-
} else {
|
141
|
+
} else if (!semisimple) {
|
142
142
|
// Suppress spacing on <mo> nodes at both ends of the row.
|
143
143
|
if (body[0] instanceof MathNode && body[0].type === "mo" && !body[0].attributes.fence) {
|
144
144
|
body[0].attributes.lspace = "0em"
|
145
|
+
body[0].attributes.rspace = "0em"
|
145
146
|
}
|
146
147
|
const end = body.length - 1
|
147
148
|
if (body[end] instanceof MathNode && body[end].type === "mo" && !body[end].attributes.fence) {
|
149
|
+
body[end].attributes.lspace = "0em"
|
148
150
|
body[end].attributes.rspace = "0em"
|
149
151
|
}
|
150
|
-
return new mathMLTree.MathNode("mrow", body);
|
151
152
|
}
|
153
|
+
return new mathMLTree.MathNode("mrow", body);
|
152
154
|
};
|
153
155
|
|
154
156
|
const isRel = item => {
|
@@ -162,10 +164,10 @@ const isRel = item => {
|
|
162
164
|
* (1) Suppress spacing when an author wraps an operator w/braces, as in {=}.
|
163
165
|
* (2) Suppress spacing between two adjacent relations.
|
164
166
|
*/
|
165
|
-
export const buildExpression = function(expression, style,
|
166
|
-
if (expression.length === 1) {
|
167
|
+
export const buildExpression = function(expression, style, semisimple = false) {
|
168
|
+
if (!semisimple && expression.length === 1) {
|
167
169
|
const group = buildGroup(expression[0], style);
|
168
|
-
if (
|
170
|
+
if (group instanceof MathNode && group.type === "mo") {
|
169
171
|
// When TeX writers want to suppress spacing on an operator,
|
170
172
|
// they often put the operator by itself inside braces.
|
171
173
|
group.setAttribute("lspace", "0em");
|
@@ -195,8 +197,8 @@ export const buildExpression = function(expression, style, isOrdgroup) {
|
|
195
197
|
* Equivalent to buildExpression, but wraps the elements in an <mrow>
|
196
198
|
* if there's more than one. Returns a single node instead of an array.
|
197
199
|
*/
|
198
|
-
export const buildExpressionRow = function(expression, style,
|
199
|
-
return makeRow(buildExpression(expression, style,
|
200
|
+
export const buildExpressionRow = function(expression, style, semisimple = false) {
|
201
|
+
return makeRow(buildExpression(expression, style, semisimple), semisimple);
|
200
202
|
};
|
201
203
|
|
202
204
|
/**
|
@@ -44,7 +44,7 @@ const getTag = (group, style, rowNum) => {
|
|
44
44
|
if (tagContents) {
|
45
45
|
// The author has written a \tag or a \notag in this row.
|
46
46
|
if (tagContents.body) {
|
47
|
-
tag = mml.buildExpressionRow(tagContents.body, style)
|
47
|
+
tag = mml.buildExpressionRow(tagContents.body, style, true)
|
48
48
|
tag.classes = ["tml-tag"]
|
49
49
|
} else {
|
50
50
|
// \notag. Return an empty span.
|
@@ -91,7 +91,9 @@ function parseArray(
|
|
91
91
|
parser.gullet.macros.set("\\cr", "\\\\\\relax");
|
92
92
|
}
|
93
93
|
if (addEqnNum) {
|
94
|
-
parser.gullet.macros.set("\\tag", "\\
|
94
|
+
parser.gullet.macros.set("\\tag", "\\@ifstar\\envtag@literal\\envtag@paren")
|
95
|
+
parser.gullet.macros.set("\\envtag@paren", "\\env@tag{{(\\text{#1})}}");
|
96
|
+
parser.gullet.macros.set("\\envtag@literal", "\\env@tag{\\text{#1}}")
|
95
97
|
parser.gullet.macros.set("\\notag", "\\env@notag");
|
96
98
|
parser.gullet.macros.set("\\nonumber", "\\env@notag")
|
97
99
|
}
|
@@ -132,7 +134,8 @@ function parseArray(
|
|
132
134
|
cell = {
|
133
135
|
type: "ordgroup",
|
134
136
|
mode: parser.mode,
|
135
|
-
body: cell
|
137
|
+
body: cell,
|
138
|
+
semisimple: true
|
136
139
|
};
|
137
140
|
row.push(cell);
|
138
141
|
const next = parser.fetch().text;
|
package/src/environments/cd.js
CHANGED
@@ -49,7 +49,8 @@ function cdArrow(arrowChar, labels, parser) {
|
|
49
49
|
const arrowGroup = {
|
50
50
|
type: "ordgroup",
|
51
51
|
mode: "math",
|
52
|
-
body: [leftLabel, sizedArrow, rightLabel]
|
52
|
+
body: [leftLabel, sizedArrow, rightLabel],
|
53
|
+
semisimple: true
|
53
54
|
};
|
54
55
|
return parser.callFunction("\\\\cdparent", [arrowGroup], []);
|
55
56
|
}
|
package/src/functions/enclose.js
CHANGED
@@ -34,20 +34,12 @@ const mathmlBuilder = (group, style) => {
|
|
34
34
|
node.style.borderBottom = "0.065em solid"
|
35
35
|
break
|
36
36
|
case "\\cancel":
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
rgba(0,0,0,1) 50%,
|
41
|
-
rgba(0,0,0,0) calc(50% + 0.06em),
|
42
|
-
rgba(0,0,0,0) 100%);`
|
37
|
+
// We can't use an inline background-gradient. It does not work client-side.
|
38
|
+
// So set a class and put the rule in the external CSS file.
|
39
|
+
node.classes.push("tml-cancel")
|
43
40
|
break
|
44
41
|
case "\\bcancel":
|
45
|
-
node.
|
46
|
-
rgba(0,0,0,0) 0%,
|
47
|
-
rgba(0,0,0,0) calc(50% - 0.06em),
|
48
|
-
rgba(0,0,0,1) 50%,
|
49
|
-
rgba(0,0,0,0) calc(50% + 0.06em),
|
50
|
-
rgba(0,0,0,0) 100%);`
|
42
|
+
node.classes.push("tml-bcancel")
|
51
43
|
break
|
52
44
|
/*
|
53
45
|
case "\\longdiv":
|
@@ -94,18 +86,7 @@ rgba(0,0,0,0) 100%);`
|
|
94
86
|
break
|
95
87
|
}
|
96
88
|
case "\\xcancel":
|
97
|
-
node.
|
98
|
-
rgba(0,0,0,0) 0%,
|
99
|
-
rgba(0,0,0,0) calc(50% - 0.06em),
|
100
|
-
rgba(0,0,0,1) 50%,
|
101
|
-
rgba(0,0,0,0) calc(50% + 0.06em),
|
102
|
-
rgba(0,0,0,0) 100%),
|
103
|
-
linear-gradient(to top right,
|
104
|
-
rgba(0,0,0,0) 0%,
|
105
|
-
rgba(0,0,0,0) calc(50% - 0.06em),
|
106
|
-
rgba(0,0,0,1) 50%,
|
107
|
-
rgba(0,0,0,0) calc(50% + 0.06em),
|
108
|
-
rgba(0,0,0,0) 100%);`
|
89
|
+
node.classes.push("tml-xcancel")
|
109
90
|
break
|
110
91
|
}
|
111
92
|
if (group.backgroundColor) {
|
package/src/functions/font.js
CHANGED
@@ -8,7 +8,7 @@ const mathmlBuilder = (group, style) => {
|
|
8
8
|
const mathGroup = mml.buildGroup(group.body, newStyle)
|
9
9
|
|
10
10
|
if (mathGroup.children.length === 0) { return mathGroup } // empty group, e.g., \mathrm{}
|
11
|
-
if (font === "boldsymbol" && ["mo", "mpadded"].includes(mathGroup.type)) {
|
11
|
+
if (font === "boldsymbol" && ["mo", "mpadded", "mrow"].includes(mathGroup.type)) {
|
12
12
|
mathGroup.style.fontWeight = "bold"
|
13
13
|
return mathGroup
|
14
14
|
}
|
package/src/functions/not.js
CHANGED
@@ -37,10 +37,10 @@ defineFunction({
|
|
37
37
|
},
|
38
38
|
mathmlBuilder(group, style) {
|
39
39
|
if (group.isCharacterBox) {
|
40
|
-
const inner = mml.buildExpression(group.body, style);
|
40
|
+
const inner = mml.buildExpression(group.body, style, true);
|
41
41
|
return inner[0]
|
42
42
|
} else {
|
43
|
-
return mml.buildExpressionRow(group.body, style
|
43
|
+
return mml.buildExpressionRow(group.body, style)
|
44
44
|
}
|
45
45
|
}
|
46
46
|
});
|
package/src/functions/op.js
CHANGED
@@ -17,6 +17,13 @@ export const ordTypes = ["textord", "mathord", "ordgroup", "close", "leftright"]
|
|
17
17
|
// NOTE: Unlike most `builders`s, this one handles not only "op", but also
|
18
18
|
// "supsub" since some of them (like \int) can affect super/subscripting.
|
19
19
|
|
20
|
+
const setSpacing = node => {
|
21
|
+
// The user wrote a \mathop{…} function. Change spacing from default to OP spacing.
|
22
|
+
// The most likely spacing for an OP is a thin space per TeXbook p170.
|
23
|
+
node.attributes.lspace = "0.1667em"
|
24
|
+
node.attributes.rspace = "0.1667em"
|
25
|
+
}
|
26
|
+
|
20
27
|
const mathmlBuilder = (group, style) => {
|
21
28
|
let node;
|
22
29
|
|
@@ -28,9 +35,11 @@ const mathmlBuilder = (group, style) => {
|
|
28
35
|
} else {
|
29
36
|
node.setAttribute("movablelimits", "false")
|
30
37
|
}
|
38
|
+
if (group.fromMathOp) { setSpacing(node) }
|
31
39
|
} else if (group.body) {
|
32
40
|
// This is an operator with children. Add them.
|
33
41
|
node = new mathMLTree.MathNode("mo", mml.buildExpression(group.body, style));
|
42
|
+
if (group.fromMathOp) { setSpacing(node) }
|
34
43
|
} else {
|
35
44
|
// This is a text operator. Add all of the characters from the operator's name.
|
36
45
|
node = new mathMLTree.MathNode("mi", [new mathMLTree.TextNode(group.name.slice(1))]);
|
@@ -150,6 +159,7 @@ defineFunction({
|
|
150
159
|
limits: true,
|
151
160
|
parentIsSupSub: false,
|
152
161
|
symbol: isSymbol,
|
162
|
+
fromMathOp: true,
|
153
163
|
stack: false,
|
154
164
|
name: isSymbol ? arr[0].text : null,
|
155
165
|
body: isSymbol ? null : ordargument(body)
|
package/src/postProcess.js
CHANGED
package/src/svg.js
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
import mathMLTree from "./mathMLTree"
|
2
|
-
import { Span, Svg } from "./domTree"
|
3
|
-
|
4
|
-
const pathGeometry = {
|
5
|
-
// tilde1 is a modified version of a glyph from the MnSymbol package
|
6
|
-
tilde1: `M200 55.538c-77 0-168 73.953-177 73.953-3 0-7
|
7
|
-
-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0
|
8
|
-
114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0
|
9
|
-
4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128
|
10
|
-
-68.267.847-113-73.952-191-73.952z`,
|
11
|
-
|
12
|
-
// ditto tilde2, tilde3, & tilde4
|
13
|
-
tilde2: `M344 55.266c-142 0-300.638 81.316-311.5 86.418
|
14
|
-
-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9
|
15
|
-
31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114
|
16
|
-
c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751
|
17
|
-
181.476 676 181.476c-149 0-189-126.21-332-126.21z`,
|
18
|
-
|
19
|
-
tilde3: `M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457
|
20
|
-
-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0
|
21
|
-
411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697
|
22
|
-
16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696
|
23
|
-
-338 0-409-156.573-744-156.573z`,
|
24
|
-
|
25
|
-
tilde4: `M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345
|
26
|
-
-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409
|
27
|
-
177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9
|
28
|
-
14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409
|
29
|
-
-175.236-744-175.236z`,
|
30
|
-
|
31
|
-
// widehat1 is a modified version of a glyph from the MnSymbol package
|
32
|
-
widehat1: `M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22
|
33
|
-
c-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z`,
|
34
|
-
|
35
|
-
// ditto widehat2, widehat3, & widehat4
|
36
|
-
widehat2: `M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10
|
37
|
-
-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,
|
38
|
-
|
39
|
-
widehat3: `M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10
|
40
|
-
-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,
|
41
|
-
|
42
|
-
widehat4: `M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10
|
43
|
-
-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z`,
|
44
|
-
|
45
|
-
// widecheck paths are all inverted versions of widehat
|
46
|
-
widecheck1: `M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,
|
47
|
-
-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z`,
|
48
|
-
|
49
|
-
widecheck2: `M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
50
|
-
-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,
|
51
|
-
|
52
|
-
widecheck3: `M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
53
|
-
-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`,
|
54
|
-
|
55
|
-
widecheck4: `M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
|
56
|
-
-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z`
|
57
|
-
|
58
|
-
}
|
59
|
-
|
60
|
-
export const svgAccent = group => {
|
61
|
-
const label = group.label.slice(1)
|
62
|
-
const numChars = group.base.type === "ordgroup" ? group.base.body.length : 1
|
63
|
-
let viewBoxWidth
|
64
|
-
let viewBoxHeight
|
65
|
-
let pathName
|
66
|
-
let height
|
67
|
-
|
68
|
-
if (numChars > 5) {
|
69
|
-
if (label === "widehat" || label === "widecheck") {
|
70
|
-
viewBoxHeight = 420;
|
71
|
-
viewBoxWidth = 2364;
|
72
|
-
height = 0.42;
|
73
|
-
pathName = label + "4";
|
74
|
-
} else {
|
75
|
-
viewBoxHeight = 312;
|
76
|
-
viewBoxWidth = 2340;
|
77
|
-
height = 0.34;
|
78
|
-
pathName = "tilde4";
|
79
|
-
}
|
80
|
-
} else {
|
81
|
-
const imgIndex = [1, 1, 2, 2, 3, 3][numChars];
|
82
|
-
if (label === "widehat" || label === "widecheck") {
|
83
|
-
viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex];
|
84
|
-
viewBoxHeight = [0, 239, 300, 360, 420][imgIndex];
|
85
|
-
height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex];
|
86
|
-
pathName = label + imgIndex;
|
87
|
-
} else {
|
88
|
-
viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex];
|
89
|
-
viewBoxHeight = [0, 260, 286, 306, 312][imgIndex];
|
90
|
-
height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex];
|
91
|
-
pathName = "tilde" + imgIndex;
|
92
|
-
}
|
93
|
-
}
|
94
|
-
const svg = new Svg(
|
95
|
-
{ width: "100%",
|
96
|
-
height: `${height}em`,
|
97
|
-
viewBox: `0 0 ${viewBoxWidth} ${viewBoxHeight}`,
|
98
|
-
preserveAspectRatio: "none"
|
99
|
-
},
|
100
|
-
pathGeometry[pathName],
|
101
|
-
null
|
102
|
-
)
|
103
|
-
const span = new Span([], [svg],
|
104
|
-
{ display: "inline-block", position: "relative", width: "100%", height: `${height}em` }
|
105
|
-
)
|
106
|
-
const node = new mathMLTree.MathNode("mo", [span], [], { "math-depth":1 })
|
107
|
-
node.setAttribute("stretchy", "true")
|
108
|
-
return node
|
109
|
-
|
110
|
-
}
|