temml 0.10.21 → 0.10.23
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/Temml-Asana.css +0 -4
- package/dist/Temml-Fira.css +152 -0
- package/dist/Temml-STIX2.css +0 -4
- package/dist/temml.cjs +162 -83
- package/dist/temml.d.ts +1 -1
- package/dist/temml.js +162 -83
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +162 -83
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +1 -1
- package/src/Parser.js +8 -1
- package/src/buildMathML.js +7 -4
- package/src/functions/color.js +1 -1
- package/src/functions/delimsizing.js +22 -7
- package/src/functions/font.js +31 -2
- package/src/functions/mclass.js +3 -0
- package/src/functions/reflect.js +24 -0
- package/src/functions/sizing.js +1 -1
- package/src/functions/styling.js +1 -1
- package/src/functions/symbolsOrd.js +0 -2
- package/src/functions.js +1 -0
- package/src/linebreaking.js +3 -2
- package/src/macros.js +49 -53
- package/src/postProcess.js +1 -1
- package/src/replace.js +8 -8
- package/src/symbols.js +7 -1
package/dist/temml.js
CHANGED
@@ -937,7 +937,8 @@ var temml = (function () {
|
|
937
937
|
defineSymbol(math, textord, "\u2200", "\\forall", true);
|
938
938
|
defineSymbol(math, textord, "\u210f", "\\hbar", true);
|
939
939
|
defineSymbol(math, textord, "\u2203", "\\exists", true);
|
940
|
-
|
940
|
+
// ∇ is actually a unary operator, not binary. But this works.
|
941
|
+
defineSymbol(math, bin, "\u2207", "\\nabla", true);
|
941
942
|
defineSymbol(math, textord, "\u266d", "\\flat", true);
|
942
943
|
defineSymbol(math, textord, "\u2113", "\\ell", true);
|
943
944
|
defineSymbol(math, textord, "\u266e", "\\natural", true);
|
@@ -991,6 +992,7 @@ var temml = (function () {
|
|
991
992
|
defineSymbol(math, bin, "\u2240", "\\wr", true);
|
992
993
|
defineSymbol(math, bin, "\u2a3f", "\\amalg");
|
993
994
|
defineSymbol(math, bin, "\u0026", "\\And"); // from amsmath
|
995
|
+
defineSymbol(math, bin, "\u2AFD", "\\sslash", true); // from stmaryrd
|
994
996
|
|
995
997
|
// Arrow Symbols
|
996
998
|
defineSymbol(math, rel, "\u27f5", "\\longleftarrow", true);
|
@@ -1025,6 +1027,7 @@ var temml = (function () {
|
|
1025
1027
|
defineSymbol(math, mathord, "\u263c", "\\sun", true);
|
1026
1028
|
defineSymbol(math, mathord, "\u263e", "\\leftmoon", true);
|
1027
1029
|
defineSymbol(math, mathord, "\u263d", "\\rightmoon", true);
|
1030
|
+
defineSymbol(math, mathord, "\u2295", "\\Earth");
|
1028
1031
|
|
1029
1032
|
// AMS Negated Binary Relations
|
1030
1033
|
defineSymbol(math, rel, "\u226e", "\\nless", true);
|
@@ -1252,6 +1255,8 @@ var temml = (function () {
|
|
1252
1255
|
defineSymbol(math, bin, "\u27d6", "\\rightouterjoin", true);
|
1253
1256
|
defineSymbol(math, bin, "\u27d7", "\\fullouterjoin", true);
|
1254
1257
|
|
1258
|
+
defineSymbol(math, bin, "\u2238", "\\dotminus", true); // stix
|
1259
|
+
|
1255
1260
|
// AMS Arrows
|
1256
1261
|
// Note: unicode-math maps \u21e2 to their own function \rightdasharrow.
|
1257
1262
|
// We'll map it to AMS function \dashrightarrow. It produces the same atom.
|
@@ -1409,6 +1414,7 @@ var temml = (function () {
|
|
1409
1414
|
defineSymbol(math, bin, "\u2217", "\u2217", true);
|
1410
1415
|
defineSymbol(math, bin, "+", "+");
|
1411
1416
|
defineSymbol(math, bin, "*", "*");
|
1417
|
+
defineSymbol(math, bin, "\u2044", "/", true);
|
1412
1418
|
defineSymbol(math, bin, "\u2044", "\u2044");
|
1413
1419
|
defineSymbol(math, bin, "\u2212", "-", true);
|
1414
1420
|
defineSymbol(math, bin, "\u22c5", "\\cdot", true);
|
@@ -1865,7 +1871,8 @@ var temml = (function () {
|
|
1865
1871
|
continue
|
1866
1872
|
}
|
1867
1873
|
block.push(node);
|
1868
|
-
if (node.type && node.type === "mo" && node.children.length === 1
|
1874
|
+
if (node.type && node.type === "mo" && node.children.length === 1 &&
|
1875
|
+
!Object.hasOwn(node.attributes, "movablelimits")) {
|
1869
1876
|
const ch = node.children[0].text;
|
1870
1877
|
if (openDelims.indexOf(ch) > -1) {
|
1871
1878
|
level += 1;
|
@@ -1880,7 +1887,7 @@ var temml = (function () {
|
|
1880
1887
|
mrows.push(element);
|
1881
1888
|
block = [node];
|
1882
1889
|
}
|
1883
|
-
} else if (level === 0 && wrapMode === "tex") {
|
1890
|
+
} else if (level === 0 && wrapMode === "tex" && ch !== "∇") {
|
1884
1891
|
// Check if the following node is a \nobreak text node, e.g. "~""
|
1885
1892
|
const next = i < expression.length - 1 ? expression[i + 1] : null;
|
1886
1893
|
let glueIsFreeOfNobreak = true;
|
@@ -2018,9 +2025,11 @@ var temml = (function () {
|
|
2018
2025
|
};
|
2019
2026
|
|
2020
2027
|
const numberRegEx$1 = /^[0-9]$/;
|
2021
|
-
const
|
2022
|
-
return (node.type === "
|
2023
|
-
|
2028
|
+
const isDotOrComma = (node, followingNode) => {
|
2029
|
+
return ((node.type === "textord" && node.text === ".") ||
|
2030
|
+
(node.type === "atom" && node.text === ",")) &&
|
2031
|
+
// Don't consolidate if there is a space after the comma.
|
2032
|
+
node.loc && followingNode.loc && node.loc.end === followingNode.loc.start
|
2024
2033
|
};
|
2025
2034
|
const consolidateNumbers = expression => {
|
2026
2035
|
// Consolidate adjacent numbers. We want to return <mn>1,506.3</mn>,
|
@@ -2043,7 +2052,8 @@ var temml = (function () {
|
|
2043
2052
|
|
2044
2053
|
// Determine if numeral groups are separated by a comma or dot.
|
2045
2054
|
for (let i = nums.length - 1; i > 0; i--) {
|
2046
|
-
if (nums[i - 1].end === nums[i].start - 2 &&
|
2055
|
+
if (nums[i - 1].end === nums[i].start - 2 &&
|
2056
|
+
isDotOrComma(expression[nums[i].start - 1], expression[nums[i].start])) {
|
2047
2057
|
// Merge the two groups.
|
2048
2058
|
nums[i - 1].end = nums[i].end;
|
2049
2059
|
nums.splice(i, 1);
|
@@ -3259,7 +3269,7 @@ var temml = (function () {
|
|
3259
3269
|
}
|
3260
3270
|
|
3261
3271
|
// Parse out the implicit body that should be colored.
|
3262
|
-
const body = parser.parseExpression(true, breakOnTokenText);
|
3272
|
+
const body = parser.parseExpression(true, breakOnTokenText, true);
|
3263
3273
|
|
3264
3274
|
return {
|
3265
3275
|
type: "color",
|
@@ -3701,17 +3711,13 @@ var temml = (function () {
|
|
3701
3711
|
|
3702
3712
|
// Delimiter functions
|
3703
3713
|
function checkDelimiter(delim, context) {
|
3704
|
-
if (delim.type === "ordgroup" && delim.body.length === 1 && delim.body[0].text === "\u2044") {
|
3705
|
-
// Recover "/" from the zero spacing group. (See macros.js)
|
3706
|
-
delim = { type: "textord", text: "/", mode: "math" };
|
3707
|
-
}
|
3708
3714
|
const symDelim = checkSymbolNodeType(delim);
|
3709
3715
|
if (symDelim && delimiters.includes(symDelim.text)) {
|
3710
3716
|
// If a character is not in the MathML operator dictionary, it will not stretch.
|
3711
3717
|
// Replace such characters w/characters that will stretch.
|
3718
|
+
if (["/", "\u2044"].includes(symDelim.text)) { symDelim.text = "\u2215"; }
|
3712
3719
|
if (["<", "\\lt"].includes(symDelim.text)) { symDelim.text = "⟨"; }
|
3713
3720
|
if ([">", "\\gt"].includes(symDelim.text)) { symDelim.text = "⟩"; }
|
3714
|
-
if (symDelim.text === "/") { symDelim.text = "\u2215"; }
|
3715
3721
|
if (symDelim.text === "\\backslash") { symDelim.text = "\u2216"; }
|
3716
3722
|
return symDelim;
|
3717
3723
|
} else if (symDelim) {
|
@@ -3820,8 +3826,26 @@ var temml = (function () {
|
|
3820
3826
|
const parser = context.parser;
|
3821
3827
|
// Parse out the implicit body
|
3822
3828
|
++parser.leftrightDepth;
|
3823
|
-
// parseExpression stops before '\\right'
|
3824
|
-
|
3829
|
+
// parseExpression stops before '\\right' or `\\middle`
|
3830
|
+
let body = parser.parseExpression(false, null, true);
|
3831
|
+
let nextToken = parser.fetch();
|
3832
|
+
while (nextToken.text === "\\middle") {
|
3833
|
+
// `\middle`, from the ε-TeX package, ends one group and starts another group.
|
3834
|
+
// We had to parse this expression with `breakOnMiddle` enabled in order
|
3835
|
+
// to get TeX-compliant parsing of \over.
|
3836
|
+
// But we do not want, at this point, to end on \middle, so continue
|
3837
|
+
// to parse until we fetch a `\right`.
|
3838
|
+
parser.consume();
|
3839
|
+
const middle = parser.fetch().text;
|
3840
|
+
if (!symbols.math[middle]) {
|
3841
|
+
throw new ParseError(`Invalid delimiter '${middle}' after '\\middle'`);
|
3842
|
+
}
|
3843
|
+
checkDelimiter({ type: "atom", mode: "math", text: middle }, { funcName: "\\middle" });
|
3844
|
+
body.push({ type: "middle", mode: "math", delim: middle });
|
3845
|
+
parser.consume();
|
3846
|
+
body = body.concat(parser.parseExpression(false, null, true));
|
3847
|
+
nextToken = parser.fetch();
|
3848
|
+
}
|
3825
3849
|
--parser.leftrightDepth;
|
3826
3850
|
// Check the next token
|
3827
3851
|
parser.expect("\\right", false);
|
@@ -5095,6 +5119,21 @@ var temml = (function () {
|
|
5095
5119
|
}
|
5096
5120
|
});
|
5097
5121
|
|
5122
|
+
const isLongVariableName = (group, font) => {
|
5123
|
+
if (font !== "mathrm" || group.body.type !== "ordgroup" || group.body.body.length === 1) {
|
5124
|
+
return false
|
5125
|
+
}
|
5126
|
+
if (group.body.body[0].type !== "mathord") { return false }
|
5127
|
+
for (let i = 1; i < group.body.body.length; i++) {
|
5128
|
+
const parseNodeType = group.body.body[i].type;
|
5129
|
+
if (!(parseNodeType === "mathord" ||
|
5130
|
+
(parseNodeType === "textord" && !isNaN(group.body.body[i].text)))) {
|
5131
|
+
return false
|
5132
|
+
}
|
5133
|
+
}
|
5134
|
+
return true
|
5135
|
+
};
|
5136
|
+
|
5098
5137
|
const mathmlBuilder$6 = (group, style) => {
|
5099
5138
|
const font = group.font;
|
5100
5139
|
const newStyle = style.withFont(font);
|
@@ -5106,6 +5145,20 @@ var temml = (function () {
|
|
5106
5145
|
return mathGroup
|
5107
5146
|
}
|
5108
5147
|
// Check if it is possible to consolidate elements into a single <mi> element.
|
5148
|
+
if (isLongVariableName(group, font)) {
|
5149
|
+
// This is a \mathrm{…} group. It gets special treatment because symbolsOrd.js
|
5150
|
+
// wraps <mi> elements with <mrow>s to work around a Firefox bug.
|
5151
|
+
const mi = mathGroup.children[0].children[0];
|
5152
|
+
delete mi.attributes.mathvariant;
|
5153
|
+
for (let i = 1; i < mathGroup.children.length; i++) {
|
5154
|
+
mi.children[0].text += mathGroup.children[i].type === "mn"
|
5155
|
+
? mathGroup.children[i].children[0].text
|
5156
|
+
: mathGroup.children[i].children[0].children[0].text;
|
5157
|
+
}
|
5158
|
+
// Wrap in a <mrow> to prevent the same Firefox bug.
|
5159
|
+
const bogus = new mathMLTree.MathNode("mtext", new mathMLTree.TextNode("\u200b"));
|
5160
|
+
return new mathMLTree.MathNode("mrow", [bogus, mi])
|
5161
|
+
}
|
5109
5162
|
let canConsolidate = mathGroup.children[0].type === "mo";
|
5110
5163
|
for (let i = 1; i < mathGroup.children.length; i++) {
|
5111
5164
|
if (mathGroup.children[i].type === "mo" && font === "boldsymbol") {
|
@@ -5196,7 +5249,7 @@ var temml = (function () {
|
|
5196
5249
|
},
|
5197
5250
|
handler: ({ parser, funcName, breakOnTokenText }, args) => {
|
5198
5251
|
const { mode } = parser;
|
5199
|
-
const body = parser.parseExpression(true, breakOnTokenText);
|
5252
|
+
const body = parser.parseExpression(true, breakOnTokenText, true);
|
5200
5253
|
const fontStyle = `math${funcName.slice(1)}`;
|
5201
5254
|
|
5202
5255
|
return {
|
@@ -6157,6 +6210,9 @@ var temml = (function () {
|
|
6157
6210
|
if (group.isCharacterBox || inner[0].type === "mathord") {
|
6158
6211
|
node = inner[0];
|
6159
6212
|
node.type = "mi";
|
6213
|
+
if (node.children.length === 1 && node.children[0].text && node.children[0].text === "∇") {
|
6214
|
+
node.setAttribute("mathvariant", "normal");
|
6215
|
+
}
|
6160
6216
|
} else {
|
6161
6217
|
node = new mathMLTree.MathNode("mi", inner);
|
6162
6218
|
}
|
@@ -7144,6 +7200,28 @@ var temml = (function () {
|
|
7144
7200
|
}
|
7145
7201
|
});
|
7146
7202
|
|
7203
|
+
defineFunction({
|
7204
|
+
type: "reflect",
|
7205
|
+
names: ["\\reflectbox"],
|
7206
|
+
props: {
|
7207
|
+
numArgs: 1,
|
7208
|
+
argTypes: ["hbox"],
|
7209
|
+
allowedInText: true
|
7210
|
+
},
|
7211
|
+
handler({ parser }, args) {
|
7212
|
+
return {
|
7213
|
+
type: "reflect",
|
7214
|
+
mode: parser.mode,
|
7215
|
+
body: args[0]
|
7216
|
+
};
|
7217
|
+
},
|
7218
|
+
mathmlBuilder(group, style) {
|
7219
|
+
const node = buildGroup$1(group.body, style);
|
7220
|
+
node.style.transform = "scaleX(-1)";
|
7221
|
+
return node
|
7222
|
+
}
|
7223
|
+
});
|
7224
|
+
|
7147
7225
|
defineFunction({
|
7148
7226
|
type: "internal",
|
7149
7227
|
names: ["\\relax"],
|
@@ -7249,7 +7327,7 @@ var temml = (function () {
|
|
7249
7327
|
// eslint-disable-next-line no-console
|
7250
7328
|
console.log(`Temml strict-mode warning: Command ${funcName} is invalid in math mode.`);
|
7251
7329
|
}
|
7252
|
-
const body = parser.parseExpression(false, breakOnTokenText);
|
7330
|
+
const body = parser.parseExpression(false, breakOnTokenText, true);
|
7253
7331
|
return {
|
7254
7332
|
type: "sizing",
|
7255
7333
|
mode: parser.mode,
|
@@ -7382,7 +7460,7 @@ var temml = (function () {
|
|
7382
7460
|
},
|
7383
7461
|
handler({ breakOnTokenText, funcName, parser }, args) {
|
7384
7462
|
// parse out the implicit body
|
7385
|
-
const body = parser.parseExpression(true, breakOnTokenText);
|
7463
|
+
const body = parser.parseExpression(true, breakOnTokenText, true);
|
7386
7464
|
|
7387
7465
|
const scriptLevel = funcName.slice(1, funcName.length - 5);
|
7388
7466
|
return {
|
@@ -7813,22 +7891,22 @@ var temml = (function () {
|
|
7813
7891
|
"sans-serif-bold-italic": ch => { return 0x1D5F5 },
|
7814
7892
|
"monospace": ch => { return 0x1D629 }
|
7815
7893
|
},
|
7816
|
-
upperCaseGreek: { // A-Ω
|
7894
|
+
upperCaseGreek: { // A-Ω
|
7817
7895
|
"normal": ch => { return 0 },
|
7818
|
-
"bold": ch => { return
|
7819
|
-
"italic": ch => { return
|
7896
|
+
"bold": ch => { return 0x1D317 },
|
7897
|
+
"italic": ch => { return 0x1D351 },
|
7820
7898
|
// \boldsymbol actually returns upright bold for upperCaseGreek
|
7821
|
-
"bold-italic": ch => { return
|
7899
|
+
"bold-italic": ch => { return 0x1D317 },
|
7822
7900
|
"script": ch => { return 0 },
|
7823
7901
|
"script-bold": ch => { return 0 },
|
7824
7902
|
"fraktur": ch => { return 0 },
|
7825
7903
|
"fraktur-bold": ch => { return 0 },
|
7826
7904
|
"double-struck": ch => { return 0 },
|
7827
7905
|
// Unicode has no code points for regular-weight san-serif Greek. Use bold.
|
7828
|
-
"sans-serif": ch => { return
|
7829
|
-
"sans-serif-bold": ch => { return
|
7906
|
+
"sans-serif": ch => { return 0x1D3C5 },
|
7907
|
+
"sans-serif-bold": ch => { return 0x1D3C5 },
|
7830
7908
|
"sans-serif-italic": ch => { return 0 },
|
7831
|
-
"sans-serif-bold-italic": ch => { return
|
7909
|
+
"sans-serif-bold-italic": ch => { return 0x1D3FF },
|
7832
7910
|
"monospace": ch => { return 0 }
|
7833
7911
|
},
|
7834
7912
|
lowerCaseGreek: { // α-ω
|
@@ -7888,7 +7966,7 @@ var temml = (function () {
|
|
7888
7966
|
? "upperCaseLatin"
|
7889
7967
|
: 0x60 < codePoint && codePoint < 0x7b
|
7890
7968
|
? "lowerCaseLatin"
|
7891
|
-
: (0x390 < codePoint && codePoint < 0x3AA)
|
7969
|
+
: (0x390 < codePoint && codePoint < 0x3AA)
|
7892
7970
|
? "upperCaseGreek"
|
7893
7971
|
: 0x3B0 < codePoint && codePoint < 0x3CA || ch === "\u03d5"
|
7894
7972
|
? "lowerCaseGreek"
|
@@ -8017,8 +8095,6 @@ var temml = (function () {
|
|
8017
8095
|
node = new mathMLTree.MathNode("mi", [text]);
|
8018
8096
|
if (text.text === origText && latinRegEx.test(origText)) {
|
8019
8097
|
node.setAttribute("mathvariant", "italic");
|
8020
|
-
} else if (text.text === "∇" && variant === "normal") {
|
8021
|
-
node.setAttribute("mathvariant", "normal");
|
8022
8098
|
}
|
8023
8099
|
}
|
8024
8100
|
return node
|
@@ -8655,6 +8731,24 @@ var temml = (function () {
|
|
8655
8731
|
return `\\@char{${number}}`;
|
8656
8732
|
});
|
8657
8733
|
|
8734
|
+
function recreateArgStr(context) {
|
8735
|
+
// Recreate the macro's original argument string from the array of parse tokens.
|
8736
|
+
const tokens = context.consumeArgs(1)[0];
|
8737
|
+
let str = "";
|
8738
|
+
let expectedLoc = tokens[tokens.length - 1].loc.start;
|
8739
|
+
for (let i = tokens.length - 1; i >= 0; i--) {
|
8740
|
+
const actualLoc = tokens[i].loc.start;
|
8741
|
+
if (actualLoc > expectedLoc) {
|
8742
|
+
// context.consumeArgs has eaten a space.
|
8743
|
+
str += " ";
|
8744
|
+
expectedLoc = actualLoc;
|
8745
|
+
}
|
8746
|
+
str += tokens[i].text;
|
8747
|
+
expectedLoc += tokens[i].text.length;
|
8748
|
+
}
|
8749
|
+
return str
|
8750
|
+
}
|
8751
|
+
|
8658
8752
|
// The Latin Modern font renders <mi>√</mi> at the wrong vertical alignment.
|
8659
8753
|
// This macro provides a better rendering.
|
8660
8754
|
defineMacro("\\surd", '\\sqrt{\\vphantom{|}}');
|
@@ -8662,10 +8756,6 @@ var temml = (function () {
|
|
8662
8756
|
// See comment for \oplus in symbols.js.
|
8663
8757
|
defineMacro("\u2295", "\\oplus");
|
8664
8758
|
|
8665
|
-
// Per TeXbook p.122, "/" gets zero operator spacing.
|
8666
|
-
// And MDN recommends using U+2044 instead of / for inline
|
8667
|
-
defineMacro("/", "{\u2044}");
|
8668
|
-
|
8669
8759
|
// Since Temml has no \par, ignore \long.
|
8670
8760
|
defineMacro("\\long", "");
|
8671
8761
|
|
@@ -9043,6 +9133,11 @@ var temml = (function () {
|
|
9043
9133
|
defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}");
|
9044
9134
|
defineMacro("\\plim", "\\DOTSB\\operatorname*{plim}");
|
9045
9135
|
|
9136
|
+
//////////////////////////////////////////////////////////////////////
|
9137
|
+
// MnSymbol.sty
|
9138
|
+
|
9139
|
+
defineMacro("\\leftmodels", "\\mathop{\\reflectbox{$\\models$}}");
|
9140
|
+
|
9046
9141
|
//////////////////////////////////////////////////////////////////////
|
9047
9142
|
// braket.sty
|
9048
9143
|
// http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf
|
@@ -9052,56 +9147,33 @@ var temml = (function () {
|
|
9052
9147
|
defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}");
|
9053
9148
|
defineMacro("\\Bra", "\\left\\langle#1\\right|");
|
9054
9149
|
defineMacro("\\Ket", "\\left|#1\\right\\rangle");
|
9055
|
-
|
9056
|
-
|
9057
|
-
const
|
9058
|
-
const
|
9059
|
-
|
9060
|
-
const oldMiddle = context.macros.get("|");
|
9061
|
-
const oldMiddleDouble = context.macros.get("\\|");
|
9062
|
-
context.macros.beginGroup();
|
9063
|
-
const midMacro = (double) => (context) => {
|
9064
|
-
if (one) {
|
9065
|
-
// Only modify the first instance of | or \|
|
9066
|
-
context.macros.set("|", oldMiddle);
|
9067
|
-
if (middleDouble.length) {
|
9068
|
-
context.macros.set("\\|", oldMiddleDouble);
|
9069
|
-
}
|
9070
|
-
}
|
9071
|
-
let doubled = double;
|
9072
|
-
if (!double && middleDouble.length) {
|
9073
|
-
// Mimic \@ifnextchar
|
9074
|
-
const nextToken = context.future();
|
9075
|
-
if (nextToken.text === "|") {
|
9076
|
-
context.popToken();
|
9077
|
-
doubled = true;
|
9078
|
-
}
|
9079
|
-
}
|
9080
|
-
return {
|
9081
|
-
tokens: doubled ? middleDouble : middle,
|
9082
|
-
numArgs: 0
|
9083
|
-
};
|
9084
|
-
};
|
9085
|
-
context.macros.set("|", midMacro(false));
|
9086
|
-
if (middleDouble.length) {
|
9087
|
-
context.macros.set("\\|", midMacro(true));
|
9088
|
-
}
|
9089
|
-
const arg = context.consumeArg().tokens;
|
9090
|
-
const expanded = context.expandTokens([...right, ...arg, ...left]); // reversed
|
9091
|
-
context.macros.endGroup();
|
9092
|
-
return {
|
9093
|
-
tokens: expanded.reverse(),
|
9094
|
-
numArgs: 0
|
9095
|
-
};
|
9150
|
+
// A helper for \Braket and \Set
|
9151
|
+
const replaceVert = (argStr, match) => {
|
9152
|
+
const ch = match[0] === "|" ? "\\vert" : "\\Vert";
|
9153
|
+
const replaceStr = `}\\,\\middle${ch}\\,{`;
|
9154
|
+
return argStr.slice(0, match.index) + replaceStr + argStr.slice(match.index + match[0].length)
|
9096
9155
|
};
|
9097
|
-
defineMacro("\\
|
9098
|
-
|
9099
|
-
|
9100
|
-
|
9101
|
-
|
9102
|
-
|
9103
|
-
|
9104
|
-
|
9156
|
+
defineMacro("\\Braket", function(context) {
|
9157
|
+
let argStr = recreateArgStr(context);
|
9158
|
+
const regEx = /\|\||\||\\\|/g;
|
9159
|
+
let match;
|
9160
|
+
while ((match = regEx.exec(argStr)) !== null) {
|
9161
|
+
argStr = replaceVert(argStr, match);
|
9162
|
+
}
|
9163
|
+
return "\\left\\langle{" + argStr + "}\\right\\rangle"
|
9164
|
+
});
|
9165
|
+
defineMacro("\\Set", function(context) {
|
9166
|
+
let argStr = recreateArgStr(context);
|
9167
|
+
const match = /\|\||\||\\\|/.exec(argStr);
|
9168
|
+
if (match) {
|
9169
|
+
argStr = replaceVert(argStr, match);
|
9170
|
+
}
|
9171
|
+
return "\\left\\{\\:{" + argStr + "}\\:\\right\\}"
|
9172
|
+
});
|
9173
|
+
defineMacro("\\set", function(context) {
|
9174
|
+
const argStr = recreateArgStr(context);
|
9175
|
+
return "\\{{" + argStr.replace(/\|/, "}\\mid{") + "}\\}"
|
9176
|
+
});
|
9105
9177
|
|
9106
9178
|
//////////////////////////////////////////////////////////////////////
|
9107
9179
|
// actuarialangle.dtx
|
@@ -10250,8 +10322,12 @@ var temml = (function () {
|
|
10250
10322
|
* `breakOnTokenText`: The text of the token that the expression should end
|
10251
10323
|
* with, or `null` if something else should end the
|
10252
10324
|
* expression.
|
10325
|
+
*
|
10326
|
+
* `breakOnMiddle`: \color, \over, and old styling functions work on an implicit group.
|
10327
|
+
* These groups end just before the usual tokens, but they also
|
10328
|
+
* end just before `\middle`.
|
10253
10329
|
*/
|
10254
|
-
parseExpression(breakOnInfix, breakOnTokenText) {
|
10330
|
+
parseExpression(breakOnInfix, breakOnTokenText, breakOnMiddle) {
|
10255
10331
|
const body = [];
|
10256
10332
|
// Keep adding atoms to the body until we can't parse any more atoms (either
|
10257
10333
|
// we reached the end, a }, or a \right)
|
@@ -10267,6 +10343,9 @@ var temml = (function () {
|
|
10267
10343
|
if (breakOnTokenText && lex.text === breakOnTokenText) {
|
10268
10344
|
break;
|
10269
10345
|
}
|
10346
|
+
if (breakOnMiddle && lex.text === "\\middle") {
|
10347
|
+
break
|
10348
|
+
}
|
10270
10349
|
if (breakOnInfix && functions[lex.text] && functions[lex.text].infix) {
|
10271
10350
|
break;
|
10272
10351
|
}
|
@@ -11245,7 +11324,7 @@ var temml = (function () {
|
|
11245
11324
|
* https://mit-license.org/
|
11246
11325
|
*/
|
11247
11326
|
|
11248
|
-
const version = "0.10.
|
11327
|
+
const version = "0.10.23";
|
11249
11328
|
|
11250
11329
|
function postProcess(block) {
|
11251
11330
|
const labelMap = {};
|