katex 0.13.9 → 0.13.13

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
@@ -1319,7 +1319,7 @@ class SvgNode {
1319
1319
  }
1320
1320
 
1321
1321
  toMarkup() {
1322
- var markup = "<svg"; // Apply attributes
1322
+ var markup = "<svg xmlns=\"http://www.w3.org/2000/svg\""; // Apply attributes
1323
1323
 
1324
1324
  for (var attr in this.attributes) {
1325
1325
  if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
@@ -7491,14 +7491,22 @@ defineFunction({
7491
7491
  props: {
7492
7492
  numArgs: 1,
7493
7493
  allowedInText: true,
7494
- allowedInMath: false,
7494
+ allowedInMath: true,
7495
+ // unless in strict mode
7495
7496
  argTypes: ["primitive"]
7496
7497
  },
7497
7498
  handler: (context, args) => {
7498
7499
  var base = args[0];
7500
+ var mode = context.parser.mode;
7501
+
7502
+ if (mode === "math") {
7503
+ context.parser.settings.reportNonstrict("mathVsTextAccents", "LaTeX's accent " + context.funcName + " works only in text mode");
7504
+ mode = "text";
7505
+ }
7506
+
7499
7507
  return {
7500
7508
  type: "accent",
7501
- mode: context.parser.mode,
7509
+ mode: mode,
7502
7510
  label: context.funcName,
7503
7511
  isStretchy: false,
7504
7512
  isShifty: true,
@@ -10633,7 +10641,8 @@ defineEnvironment({
10633
10641
 
10634
10642
  var res = parseArray(context.parser, payload, dCellStyle(context.envName)); // Populate cols with the correct number of column alignment specs.
10635
10643
 
10636
- res.cols = new Array(res.body[0].length).fill({
10644
+ var numCols = Math.max(0, ...res.body.map(row => row.length));
10645
+ res.cols = new Array(numCols).fill({
10637
10646
  type: "align",
10638
10647
  align: colAlign
10639
10648
  });
@@ -12548,6 +12557,7 @@ defineFunction({
12548
12557
  // For an operator with limits, assemble the base, sup, and sub into a span.
12549
12558
  var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => {
12550
12559
  base = buildCommon.makeSpan([], [base]);
12560
+ var subIsSingleCharacter = subGroup && utils.isCharacterBox(subGroup);
12551
12561
  var sub;
12552
12562
  var sup; // We manually have to handle the superscripts and subscripts. This,
12553
12563
  // aside from the kern calculations, is copied from supsub.
@@ -12655,7 +12665,17 @@ var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift
12655
12665
  return base;
12656
12666
  }
12657
12667
 
12658
- return buildCommon.makeSpan(["mop", "op-limits"], [finalGroup], options);
12668
+ var parts = [finalGroup];
12669
+
12670
+ if (sub && slant !== 0 && !subIsSingleCharacter) {
12671
+ // A negative margin-left was applied to the lower limit.
12672
+ // Avoid an overlap by placing a spacer on the left on the group.
12673
+ var spacer = buildCommon.makeSpan(["mspace"], [], options);
12674
+ spacer.style.marginRight = slant + "em";
12675
+ parts.unshift(spacer);
12676
+ }
12677
+
12678
+ return buildCommon.makeSpan(["mop", "op-limits"], parts, options);
12659
12679
  };
12660
12680
 
12661
12681
  // Limits, symbols
@@ -17622,7 +17642,7 @@ var katex = {
17622
17642
  /**
17623
17643
  * Current KaTeX version
17624
17644
  */
17625
- version: "0.13.9",
17645
+ version: "0.13.13",
17626
17646
 
17627
17647
  /**
17628
17648
  * 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.13.9",
3
+ "version": "0.13.13",
4
4
  "description": "Fast math typesetting for the web.",
5
5
  "main": "dist/katex.js",
6
6
  "homepage": "https://katex.org",
@@ -46,7 +46,7 @@
46
46
  "eslint-plugin-react": "^7.20.3",
47
47
  "file-loader": "^6.0.0",
48
48
  "flow-bin": "^0.135.0",
49
- "fs-extra": "^9.0.1",
49
+ "fs-extra": "^10.0.0",
50
50
  "got": "^11.8.0",
51
51
  "husky": "^4.2.5",
52
52
  "istanbul-lib-coverage": "^3.0.0",
@@ -61,7 +61,7 @@
61
61
  "json-stable-stringify": "^1.0.1",
62
62
  "jspngopt": "^0.2.0",
63
63
  "less": "^4.0.0",
64
- "less-loader": "^8.0.0",
64
+ "less-loader": "^9.0.0",
65
65
  "mini-css-extract-plugin": "^1.0.0",
66
66
  "mkdirp": "^1.0.4",
67
67
  "pako": "^2.0.0",
package/src/domTree.js CHANGED
@@ -505,7 +505,7 @@ export class SvgNode implements VirtualNode {
505
505
  }
506
506
 
507
507
  toMarkup(): string {
508
- let markup = "<svg";
508
+ let markup = `<svg xmlns="http://www.w3.org/2000/svg"`;
509
509
 
510
510
  // Apply attributes
511
511
  for (const attr in this.attributes) {
@@ -820,7 +820,8 @@ defineEnvironment({
820
820
  const res: ParseNode<"array"> =
821
821
  parseArray(context.parser, payload, dCellStyle(context.envName));
822
822
  // Populate cols with the correct number of column alignment specs.
823
- res.cols = new Array(res.body[0].length).fill(
823
+ const numCols = Math.max(0, ...res.body.map((row) => row.length));
824
+ res.cols = new Array(numCols).fill(
824
825
  {type: "align", align: colAlign}
825
826
  );
826
827
  return delimiters ? {
@@ -249,15 +249,22 @@ defineFunction({
249
249
  props: {
250
250
  numArgs: 1,
251
251
  allowedInText: true,
252
- allowedInMath: false,
252
+ allowedInMath: true, // unless in strict mode
253
253
  argTypes: ["primitive"],
254
254
  },
255
255
  handler: (context, args) => {
256
256
  const base = args[0];
257
+ let mode = context.parser.mode;
258
+
259
+ if (mode === "math") {
260
+ context.parser.settings.reportNonstrict("mathVsTextAccents",
261
+ `LaTeX's accent ${context.funcName} works only in text mode`);
262
+ mode = "text";
263
+ }
257
264
 
258
265
  return {
259
266
  type: "accent",
260
- mode: context.parser.mode,
267
+ mode: mode,
261
268
  label: context.funcName,
262
269
  isStretchy: false,
263
270
  isShifty: true,
@@ -1,6 +1,7 @@
1
1
  // @flow
2
2
  import buildCommon from "../../buildCommon";
3
3
  import * as html from "../../buildHTML";
4
+ import utils from "../../utils";
4
5
  import type {StyleInterface} from "../../Style";
5
6
  import type Options from "../../Options";
6
7
  import type {DomSpan, SymbolNode} from "../../domTree";
@@ -18,6 +19,7 @@ export const assembleSupSub = (
18
19
  baseShift: number,
19
20
  ): DomSpan => {
20
21
  base = buildCommon.makeSpan([], [base]);
22
+ const subIsSingleCharacter = subGroup && utils.isCharacterBox(subGroup);
21
23
  let sub;
22
24
  let sup;
23
25
  // We manually have to handle the superscripts and subscripts. This,
@@ -105,6 +107,13 @@ export const assembleSupSub = (
105
107
  return base;
106
108
  }
107
109
 
108
- return buildCommon.makeSpan(
109
- ["mop", "op-limits"], [finalGroup], options);
110
+ const parts = [finalGroup];
111
+ if (sub && slant !== 0 && !subIsSingleCharacter) {
112
+ // A negative margin-left was applied to the lower limit.
113
+ // Avoid an overlap by placing a spacer on the left on the group.
114
+ const spacer = buildCommon.makeSpan(["mspace"], [], options);
115
+ spacer.style.marginRight = `${slant}em`;
116
+ parts.unshift(spacer);
117
+ }
118
+ return buildCommon.makeSpan(["mop", "op-limits"], parts, options);
110
119
  };
package/src/katex.less CHANGED
@@ -593,7 +593,7 @@
593
593
 
594
594
  .angl {
595
595
  // from package actuarialangle, which is always used in a subscript.
596
- box-sizing: border-content;
596
+ box-sizing: border-box;
597
597
  border-top: 0.049em solid; // defaultRuleThickness in scriptstyle
598
598
  border-right: 0.049em solid; // ditto
599
599
  margin-right: 0.03889em; // 1 mu