katex 0.15.1 → 0.15.4

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/katex.mjs CHANGED
@@ -4465,7 +4465,7 @@ defineSymbol(math, main, bin, "\u2293", "\\sqcap", true);
4465
4465
  defineSymbol(math, main, bin, "\u2217", "\\ast");
4466
4466
  defineSymbol(math, main, bin, "\u2294", "\\sqcup", true);
4467
4467
  defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true);
4468
- defineSymbol(math, main, bin, "\u2219", "\\bullet");
4468
+ defineSymbol(math, main, bin, "\u2219", "\\bullet", true);
4469
4469
  defineSymbol(math, main, bin, "\u2021", "\\ddagger");
4470
4470
  defineSymbol(math, main, bin, "\u2240", "\\wr", true);
4471
4471
  defineSymbol(math, main, bin, "\u2a3f", "\\amalg");
@@ -4824,13 +4824,13 @@ defineSymbol(math, main, bin, "\u2217", "*", true);
4824
4824
  defineSymbol(math, main, bin, "+", "+");
4825
4825
  defineSymbol(math, main, bin, "\u2212", "-", true);
4826
4826
  defineSymbol(math, main, bin, "\u22c5", "\\cdot", true);
4827
- defineSymbol(math, main, bin, "\u2218", "\\circ");
4827
+ defineSymbol(math, main, bin, "\u2218", "\\circ", true);
4828
4828
  defineSymbol(math, main, bin, "\u00f7", "\\div", true);
4829
4829
  defineSymbol(math, main, bin, "\u00b1", "\\pm", true);
4830
4830
  defineSymbol(math, main, bin, "\u00d7", "\\times", true);
4831
4831
  defineSymbol(math, main, bin, "\u2229", "\\cap", true);
4832
4832
  defineSymbol(math, main, bin, "\u222a", "\\cup", true);
4833
- defineSymbol(math, main, bin, "\u2216", "\\setminus");
4833
+ defineSymbol(math, main, bin, "\u2216", "\\setminus", true);
4834
4834
  defineSymbol(math, main, bin, "\u2227", "\\land");
4835
4835
  defineSymbol(math, main, bin, "\u2228", "\\lor");
4836
4836
  defineSymbol(math, main, bin, "\u2227", "\\wedge", true);
@@ -11191,7 +11191,7 @@ function mathmlBuilder$5(group, options) {
11191
11191
  var inner = buildExpression(group.body, options);
11192
11192
 
11193
11193
  if (group.mclass === "minner") {
11194
- return mathMLTree.newDocumentFragment(inner);
11194
+ node = new mathMLTree.MathNode("mpadded", inner);
11195
11195
  } else if (group.mclass === "mord") {
11196
11196
  if (group.isCharacterBox) {
11197
11197
  node = inner[0];
@@ -11219,6 +11219,10 @@ function mathmlBuilder$5(group, options) {
11219
11219
  } else if (group.mclass === "mopen" || group.mclass === "mclose") {
11220
11220
  node.attributes.lspace = "0em";
11221
11221
  node.attributes.rspace = "0em";
11222
+ } else if (group.mclass === "minner") {
11223
+ node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option
11224
+
11225
+ node.attributes.width = "+0.1111em";
11222
11226
  } // MathML <mo> default space is 5/18 em, so <mrel> needs no action.
11223
11227
  // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
11224
11228
 
@@ -16362,6 +16366,113 @@ class MacroExpander {
16362
16366
 
16363
16367
  }
16364
16368
 
16369
+ // Helpers for Parser.js handling of Unicode (sub|super)script characters.
16370
+ var unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/;
16371
+ var uSubsAndSups = Object.freeze({
16372
+ '₊': '+',
16373
+ '₋': '-',
16374
+ '₌': '=',
16375
+ '₍': '(',
16376
+ '₎': ')',
16377
+ '₀': '0',
16378
+ '₁': '1',
16379
+ '₂': '2',
16380
+ '₃': '3',
16381
+ '₄': '4',
16382
+ '₅': '5',
16383
+ '₆': '6',
16384
+ '₇': '7',
16385
+ '₈': '8',
16386
+ '₉': '9',
16387
+ '\u2090': 'a',
16388
+ '\u2091': 'e',
16389
+ '\u2095': 'h',
16390
+ '\u1D62': 'i',
16391
+ '\u2C7C': 'j',
16392
+ '\u2096': 'k',
16393
+ '\u2097': 'l',
16394
+ '\u2098': 'm',
16395
+ '\u2099': 'n',
16396
+ '\u2092': 'o',
16397
+ '\u209A': 'p',
16398
+ '\u1D63': 'r',
16399
+ '\u209B': 's',
16400
+ '\u209C': 't',
16401
+ '\u1D64': 'u',
16402
+ '\u1D65': 'v',
16403
+ '\u2093': 'x',
16404
+ '\u1D66': 'β',
16405
+ '\u1D67': 'γ',
16406
+ '\u1D68': 'ρ',
16407
+ '\u1D69': '\u03d5',
16408
+ '\u1D6A': 'χ',
16409
+ '⁺': '+',
16410
+ '⁻': '-',
16411
+ '⁼': '=',
16412
+ '⁽': '(',
16413
+ '⁾': ')',
16414
+ '⁰': '0',
16415
+ '¹': '1',
16416
+ '²': '2',
16417
+ '³': '3',
16418
+ '⁴': '4',
16419
+ '⁵': '5',
16420
+ '⁶': '6',
16421
+ '⁷': '7',
16422
+ '⁸': '8',
16423
+ '⁹': '9',
16424
+ '\u1D2C': 'A',
16425
+ '\u1D2E': 'B',
16426
+ '\u1D30': 'D',
16427
+ '\u1D31': 'E',
16428
+ '\u1D33': 'G',
16429
+ '\u1D34': 'H',
16430
+ '\u1D35': 'I',
16431
+ '\u1D36': 'J',
16432
+ '\u1D37': 'K',
16433
+ '\u1D38': 'L',
16434
+ '\u1D39': 'M',
16435
+ '\u1D3A': 'N',
16436
+ '\u1D3C': 'O',
16437
+ '\u1D3E': 'P',
16438
+ '\u1D3F': 'R',
16439
+ '\u1D40': 'T',
16440
+ '\u1D41': 'U',
16441
+ '\u2C7D': 'V',
16442
+ '\u1D42': 'W',
16443
+ '\u1D43': 'a',
16444
+ '\u1D47': 'b',
16445
+ '\u1D9C': 'c',
16446
+ '\u1D48': 'd',
16447
+ '\u1D49': 'e',
16448
+ '\u1DA0': 'f',
16449
+ '\u1D4D': 'g',
16450
+ '\u02B0': 'h',
16451
+ '\u2071': 'i',
16452
+ '\u02B2': 'j',
16453
+ '\u1D4F': 'k',
16454
+ '\u02E1': 'l',
16455
+ '\u1D50': 'm',
16456
+ '\u207F': 'n',
16457
+ '\u1D52': 'o',
16458
+ '\u1D56': 'p',
16459
+ '\u02B3': 'r',
16460
+ '\u02E2': 's',
16461
+ '\u1D57': 't',
16462
+ '\u1D58': 'u',
16463
+ '\u1D5B': 'v',
16464
+ '\u02B7': 'w',
16465
+ '\u02E3': 'x',
16466
+ '\u02B8': 'y',
16467
+ '\u1DBB': 'z',
16468
+ '\u1D5D': 'β',
16469
+ '\u1D5E': 'γ',
16470
+ '\u1D5F': 'δ',
16471
+ '\u1D60': '\u03d5',
16472
+ '\u1D61': 'χ',
16473
+ '\u1DBF': 'θ'
16474
+ });
16475
+
16365
16476
  /* eslint no-constant-condition:0 */
16366
16477
 
16367
16478
  var unicodeAccents = {
@@ -17160,6 +17271,46 @@ class Parser {
17160
17271
  mode: this.mode,
17161
17272
  body: primes
17162
17273
  };
17274
+ } else if (uSubsAndSups[lex.text]) {
17275
+ // A Unicode subscript or superscript character.
17276
+ // We treat these similarly to the unicode-math package.
17277
+ // So we render a string of Unicode (sub|super)scripts the
17278
+ // same as a (sub|super)script of regular characters.
17279
+ var str = uSubsAndSups[lex.text];
17280
+ var isSub = unicodeSubRegEx.test(lex.text);
17281
+ this.consume(); // Continue fetching tokens to fill out the string.
17282
+
17283
+ while (true) {
17284
+ var token = this.fetch().text;
17285
+
17286
+ if (!uSubsAndSups[token]) {
17287
+ break;
17288
+ }
17289
+
17290
+ if (unicodeSubRegEx.test(token) !== isSub) {
17291
+ break;
17292
+ }
17293
+
17294
+ this.consume();
17295
+ str += uSubsAndSups[token];
17296
+ } // Now create a (sub|super)script.
17297
+
17298
+
17299
+ var body = new Parser(str, this.settings).parse();
17300
+
17301
+ if (isSub) {
17302
+ subscript = {
17303
+ type: "ordgroup",
17304
+ mode: "math",
17305
+ body
17306
+ };
17307
+ } else {
17308
+ superscript = {
17309
+ type: "ordgroup",
17310
+ mode: "math",
17311
+ body
17312
+ };
17313
+ }
17163
17314
  } else {
17164
17315
  // If it wasn't ^, _, or ', stop parsing super/subscripts
17165
17316
  break;
@@ -17955,7 +18106,7 @@ var katex = {
17955
18106
  /**
17956
18107
  * Current KaTeX version
17957
18108
  */
17958
- version: "0.15.1",
18109
+ version: "0.15.4",
17959
18110
 
17960
18111
  /**
17961
18112
  * Renders the given LaTeX into an HTML+MathML combination, and adds
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "katex",
3
- "version": "0.15.1",
3
+ "version": "0.15.4",
4
4
  "description": "Fast math typesetting for the web.",
5
5
  "main": "dist/katex.js",
6
6
  "exports": {
@@ -47,7 +47,7 @@
47
47
  "dist/"
48
48
  ],
49
49
  "license": "MIT",
50
- "packageManager": "yarn@3.0.1",
50
+ "packageManager": "yarn@3.2.0",
51
51
  "devDependencies": {
52
52
  "@babel/core": "^7.10.4",
53
53
  "@babel/eslint-parser": "^7.15.0",
@@ -103,9 +103,9 @@
103
103
  "p-retry": "^4.6.1",
104
104
  "pako": "^2.0.0",
105
105
  "postcss": "^8.0.0",
106
- "postcss-less": "^5.0.0",
106
+ "postcss-less": "^6.0.0",
107
107
  "postcss-loader": "^6.0.0",
108
- "postcss-preset-env": "^6.7.0",
108
+ "postcss-preset-env": "^7.0.0",
109
109
  "prettier": "^2.0.5",
110
110
  "query-string": "^7.0.0",
111
111
  "rimraf": "^3.0.2",
@@ -115,7 +115,7 @@
115
115
  "sri-toolbox": "^0.2.0",
116
116
  "style-loader": "^3.0.0",
117
117
  "stylelint": "^14.0.0",
118
- "stylelint-config-standard": "^23.0.0",
118
+ "stylelint-config-standard": "^24.0.0",
119
119
  "terser-webpack-plugin": "^5.0.3",
120
120
  "webpack": "^5.51.1",
121
121
  "webpack-bundle-analyzer": "^4.0.0",
package/src/Parser.js CHANGED
@@ -9,6 +9,7 @@ import ParseError from "./ParseError";
9
9
  import {combiningDiacriticalMarksEndRegex} from "./Lexer";
10
10
  import Settings from "./Settings";
11
11
  import SourceLocation from "./SourceLocation";
12
+ import {uSubsAndSups, unicodeSubRegEx} from "./unicodeSupOrSub";
12
13
  import {Token} from "./Token";
13
14
 
14
15
  // Pre-evaluate both modules as unicodeSymbols require String.normalize()
@@ -399,6 +400,29 @@ export default class Parser {
399
400
  }
400
401
  // Put everything into an ordgroup as the superscript
401
402
  superscript = {type: "ordgroup", mode: this.mode, body: primes};
403
+ } else if (uSubsAndSups[lex.text]) {
404
+ // A Unicode subscript or superscript character.
405
+ // We treat these similarly to the unicode-math package.
406
+ // So we render a string of Unicode (sub|super)scripts the
407
+ // same as a (sub|super)script of regular characters.
408
+ let str = uSubsAndSups[lex.text];
409
+ const isSub = unicodeSubRegEx.test(lex.text);
410
+ this.consume();
411
+ // Continue fetching tokens to fill out the string.
412
+ while (true) {
413
+ const token = this.fetch().text;
414
+ if (!(uSubsAndSups[token])) { break; }
415
+ if (unicodeSubRegEx.test(token) !== isSub) { break; }
416
+ this.consume();
417
+ str += uSubsAndSups[token];
418
+ }
419
+ // Now create a (sub|super)script.
420
+ const body = (new Parser(str, this.settings)).parse();
421
+ if (isSub) {
422
+ subscript = {type: "ordgroup", mode: "math", body};
423
+ } else {
424
+ superscript = {type: "ordgroup", mode: "math", body};
425
+ }
402
426
  } else {
403
427
  // If it wasn't ^, _, or ', stop parsing super/subscripts
404
428
  break;
@@ -22,7 +22,7 @@ function mathmlBuilder(group: ParseNode<"mclass">, options) {
22
22
  const inner = mml.buildExpression(group.body, options);
23
23
 
24
24
  if (group.mclass === "minner") {
25
- return mathMLTree.newDocumentFragment(inner);
25
+ node = new mathMLTree.MathNode("mpadded", inner);
26
26
  } else if (group.mclass === "mord") {
27
27
  if (group.isCharacterBox) {
28
28
  node = inner[0];
@@ -49,6 +49,9 @@ function mathmlBuilder(group: ParseNode<"mclass">, options) {
49
49
  } else if (group.mclass === "mopen" || group.mclass === "mclose") {
50
50
  node.attributes.lspace = "0em";
51
51
  node.attributes.rspace = "0em";
52
+ } else if (group.mclass === "minner") {
53
+ node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option
54
+ node.attributes.width = "+0.1111em";
52
55
  }
53
56
  // MathML <mo> default space is 5/18 em, so <mrel> needs no action.
54
57
  // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
package/src/symbols.js CHANGED
@@ -171,7 +171,7 @@ defineSymbol(math, main, bin, "\u2293", "\\sqcap", true);
171
171
  defineSymbol(math, main, bin, "\u2217", "\\ast");
172
172
  defineSymbol(math, main, bin, "\u2294", "\\sqcup", true);
173
173
  defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true);
174
- defineSymbol(math, main, bin, "\u2219", "\\bullet");
174
+ defineSymbol(math, main, bin, "\u2219", "\\bullet", true);
175
175
  defineSymbol(math, main, bin, "\u2021", "\\ddagger");
176
176
  defineSymbol(math, main, bin, "\u2240", "\\wr", true);
177
177
  defineSymbol(math, main, bin, "\u2a3f", "\\amalg");
@@ -538,13 +538,13 @@ defineSymbol(math, main, bin, "\u2217", "*", true);
538
538
  defineSymbol(math, main, bin, "+", "+");
539
539
  defineSymbol(math, main, bin, "\u2212", "-", true);
540
540
  defineSymbol(math, main, bin, "\u22c5", "\\cdot", true);
541
- defineSymbol(math, main, bin, "\u2218", "\\circ");
541
+ defineSymbol(math, main, bin, "\u2218", "\\circ", true);
542
542
  defineSymbol(math, main, bin, "\u00f7", "\\div", true);
543
543
  defineSymbol(math, main, bin, "\u00b1", "\\pm", true);
544
544
  defineSymbol(math, main, bin, "\u00d7", "\\times", true);
545
545
  defineSymbol(math, main, bin, "\u2229", "\\cap", true);
546
546
  defineSymbol(math, main, bin, "\u222a", "\\cup", true);
547
- defineSymbol(math, main, bin, "\u2216", "\\setminus");
547
+ defineSymbol(math, main, bin, "\u2216", "\\setminus", true);
548
548
  defineSymbol(math, main, bin, "\u2227", "\\land");
549
549
  defineSymbol(math, main, bin, "\u2228", "\\lor");
550
550
  defineSymbol(math, main, bin, "\u2227", "\\wedge", true);
@@ -0,0 +1,108 @@
1
+ // Helpers for Parser.js handling of Unicode (sub|super)script characters.
2
+
3
+ export const unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/;
4
+
5
+ export const uSubsAndSups = Object.freeze({
6
+ '₊': '+',
7
+ '₋': '-',
8
+ '₌': '=',
9
+ '₍': '(',
10
+ '₎': ')',
11
+ '₀': '0',
12
+ '₁': '1',
13
+ '₂': '2',
14
+ '₃': '3',
15
+ '₄': '4',
16
+ '₅': '5',
17
+ '₆': '6',
18
+ '₇': '7',
19
+ '₈': '8',
20
+ '₉': '9',
21
+ '\u2090': 'a',
22
+ '\u2091': 'e',
23
+ '\u2095': 'h',
24
+ '\u1D62': 'i',
25
+ '\u2C7C': 'j',
26
+ '\u2096': 'k',
27
+ '\u2097': 'l',
28
+ '\u2098': 'm',
29
+ '\u2099': 'n',
30
+ '\u2092': 'o',
31
+ '\u209A': 'p',
32
+ '\u1D63': 'r',
33
+ '\u209B': 's',
34
+ '\u209C': 't',
35
+ '\u1D64': 'u',
36
+ '\u1D65': 'v',
37
+ '\u2093': 'x',
38
+ '\u1D66': 'β',
39
+ '\u1D67': 'γ',
40
+ '\u1D68': 'ρ',
41
+ '\u1D69': '\u03d5',
42
+ '\u1D6A': 'χ',
43
+ '⁺': '+',
44
+ '⁻': '-',
45
+ '⁼': '=',
46
+ '⁽': '(',
47
+ '⁾': ')',
48
+ '⁰': '0',
49
+ '¹': '1',
50
+ '²': '2',
51
+ '³': '3',
52
+ '⁴': '4',
53
+ '⁵': '5',
54
+ '⁶': '6',
55
+ '⁷': '7',
56
+ '⁸': '8',
57
+ '⁹': '9',
58
+ '\u1D2C': 'A',
59
+ '\u1D2E': 'B',
60
+ '\u1D30': 'D',
61
+ '\u1D31': 'E',
62
+ '\u1D33': 'G',
63
+ '\u1D34': 'H',
64
+ '\u1D35': 'I',
65
+ '\u1D36': 'J',
66
+ '\u1D37': 'K',
67
+ '\u1D38': 'L',
68
+ '\u1D39': 'M',
69
+ '\u1D3A': 'N',
70
+ '\u1D3C': 'O',
71
+ '\u1D3E': 'P',
72
+ '\u1D3F': 'R',
73
+ '\u1D40': 'T',
74
+ '\u1D41': 'U',
75
+ '\u2C7D': 'V',
76
+ '\u1D42': 'W',
77
+ '\u1D43': 'a',
78
+ '\u1D47': 'b',
79
+ '\u1D9C': 'c',
80
+ '\u1D48': 'd',
81
+ '\u1D49': 'e',
82
+ '\u1DA0': 'f',
83
+ '\u1D4D': 'g',
84
+ '\u02B0': 'h',
85
+ '\u2071': 'i',
86
+ '\u02B2': 'j',
87
+ '\u1D4F': 'k',
88
+ '\u02E1': 'l',
89
+ '\u1D50': 'm',
90
+ '\u207F': 'n',
91
+ '\u1D52': 'o',
92
+ '\u1D56': 'p',
93
+ '\u02B3': 'r',
94
+ '\u02E2': 's',
95
+ '\u1D57': 't',
96
+ '\u1D58': 'u',
97
+ '\u1D5B': 'v',
98
+ '\u02B7': 'w',
99
+ '\u02E3': 'x',
100
+ '\u02B8': 'y',
101
+ '\u1DBB': 'z',
102
+ '\u1D5D': 'β',
103
+ '\u1D5E': 'γ',
104
+ '\u1D5F': 'δ',
105
+ '\u1D60': '\u03d5',
106
+ '\u1D61': 'χ',
107
+ '\u1DBF': 'θ',
108
+ });