katex 0.18.0 → 0.18.2

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
@@ -248,15 +248,16 @@ function getImplicitDefault(type) {
248
248
  }
249
249
  }
250
250
  function getDefaultValue(schema) {
251
- if (schema.default !== undefined) {
251
+ if (Object.prototype.hasOwnProperty.call(schema, "default") && schema.default !== undefined) {
252
252
  return schema.default;
253
253
  }
254
254
  var type = Array.isArray(schema.type) ? schema.type[0] : schema.type;
255
255
  return getImplicitDefault(type);
256
256
  }
257
257
  function applySetting(target, prop, options, schema) {
258
- var optionValue = options[prop];
259
- target[prop] = optionValue !== undefined ? schema.processor ? schema.processor(optionValue) : optionValue : getDefaultValue(schema);
258
+ var optionValue = Object.prototype.hasOwnProperty.call(options, prop) ? options[prop] : undefined;
259
+ var processor = Object.prototype.hasOwnProperty.call(schema, "processor") ? schema.processor : undefined;
260
+ target[prop] = optionValue !== undefined ? processor ? processor(optionValue) : optionValue : getDefaultValue(schema);
260
261
  }
261
262
  /**
262
263
  * The main Settings object
@@ -11125,9 +11126,26 @@ defineFunction({
11125
11126
  break;
11126
11127
  case "\\htmlData":
11127
11128
  {
11128
- var data = value.split(",");
11129
- for (var i = 0; i < data.length; i++) {
11130
- var item = data[i];
11129
+ // `{,}` escapes a literal comma. Braces are used rather than a
11130
+ // backslash because `\,` is a macro (a thin space) that expands
11131
+ // away before this raw argument is ever read.
11132
+ var ESCAPED_COMMA = "{,}";
11133
+ var data = [];
11134
+ var current = "";
11135
+ for (var i = 0; i < value.length; i++) {
11136
+ if (value.startsWith(ESCAPED_COMMA, i)) {
11137
+ current += ",";
11138
+ i += ESCAPED_COMMA.length - 1;
11139
+ } else if (value[i] === ",") {
11140
+ data.push(current);
11141
+ current = "";
11142
+ } else {
11143
+ current += value[i];
11144
+ }
11145
+ }
11146
+ data.push(current);
11147
+ for (var _i = 0; _i < data.length; _i++) {
11148
+ var item = data[_i];
11131
11149
  var firstEquals = item.indexOf("=");
11132
11150
  if (firstEquals < 0) {
11133
11151
  throw new ParseError("\\htmlData key/value '" + item + "'" + " missing equals sign");
@@ -13319,8 +13337,10 @@ class Namespace {
13319
13337
  get(name) {
13320
13338
  if (Object.prototype.hasOwnProperty.call(this.current, name)) {
13321
13339
  return this.current[name];
13322
- } else {
13340
+ } else if (Object.prototype.hasOwnProperty.call(this.builtins, name)) {
13323
13341
  return this.builtins[name];
13342
+ } else {
13343
+ return undefined;
13324
13344
  }
13325
13345
  }
13326
13346
  /**
@@ -13351,7 +13371,7 @@ class Namespace {
13351
13371
  // value is the correct one.
13352
13372
  var top = this.undefStack[this.undefStack.length - 1];
13353
13373
  if (top && !Object.prototype.hasOwnProperty.call(top, name)) {
13354
- top[name] = this.current[name];
13374
+ top[name] = Object.prototype.hasOwnProperty.call(this.current, name) ? this.current[name] : undefined;
13355
13375
  }
13356
13376
  }
13357
13377
  if (value == null) {
@@ -16245,7 +16265,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
16245
16265
  return renderError(error, expression, settings);
16246
16266
  }
16247
16267
  };
16248
- var version = "0.18.0";
16268
+ var version = "0.18.2";
16249
16269
  var __domTree = {
16250
16270
  Span,
16251
16271
  Anchor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "katex",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
4
4
  "description": "Fast math typesetting for the web.",
5
5
  "main": "dist/katex.js",
6
6
  "types": "types/katex.d.ts",
@@ -109,6 +109,8 @@
109
109
  "mkdirp": "^1.0.4",
110
110
  "p-retry": "^4.6.2",
111
111
  "pako": "^2.0.4",
112
+ "pixelmatch": "^7.2.0",
113
+ "pngjs": "^7.0.0",
112
114
  "postcss": "^8.4.16",
113
115
  "postcss-loader": "^7.0.1",
114
116
  "postcss-preset-env": "^7.8.0",
package/src/Namespace.ts CHANGED
@@ -81,8 +81,10 @@ export default class Namespace<Value> {
81
81
  get(name: string): Value | undefined {
82
82
  if (Object.prototype.hasOwnProperty.call(this.current, name)) {
83
83
  return this.current[name];
84
- } else {
84
+ } else if (Object.prototype.hasOwnProperty.call(this.builtins, name)) {
85
85
  return this.builtins[name];
86
+ } else {
87
+ return undefined;
86
88
  }
87
89
  }
88
90
 
@@ -111,7 +113,8 @@ export default class Namespace<Value> {
111
113
  // value is the correct one.
112
114
  const top = this.undefStack[this.undefStack.length - 1];
113
115
  if (top && !Object.prototype.hasOwnProperty.call(top, name)) {
114
- top[name] = this.current[name];
116
+ top[name] = Object.prototype.hasOwnProperty.call(
117
+ this.current, name) ? this.current[name] : undefined;
115
118
  }
116
119
  }
117
120
  if (value == null) {
package/src/Settings.ts CHANGED
@@ -326,7 +326,8 @@ function getDefaultValue<K extends keyof SettingsOptions>(
326
326
  schema: SchemaEntry<K>,
327
327
  ): Settings[K];
328
328
  function getDefaultValue(schema: SchemaEntry<keyof SettingsOptions>): DefaultValue {
329
- if (schema.default !== undefined) {
329
+ if (Object.prototype.hasOwnProperty.call(schema, "default") &&
330
+ schema.default !== undefined) {
330
331
  return schema.default;
331
332
  }
332
333
  const type = Array.isArray(schema.type) ? schema.type[0] : schema.type;
@@ -339,10 +340,13 @@ function applySetting<K extends keyof SettingsOptions>(
339
340
  options: SettingsOptions,
340
341
  schema: SchemaEntry<K>,
341
342
  ) {
342
- const optionValue = options[prop];
343
+ const optionValue = Object.prototype.hasOwnProperty.call(options, prop)
344
+ ? options[prop] : undefined;
345
+ const processor = Object.prototype.hasOwnProperty.call(schema, "processor")
346
+ ? schema.processor : undefined;
343
347
  target[prop] = optionValue !== undefined
344
- ? (schema.processor
345
- ? schema.processor(optionValue)
348
+ ? (processor
349
+ ? processor(optionValue)
346
350
  : optionValue)
347
351
  : getDefaultValue(schema);
348
352
  }
@@ -49,7 +49,24 @@ defineFunction({
49
49
  };
50
50
  break;
51
51
  case "\\htmlData": {
52
- const data = value.split(",");
52
+ // `{,}` escapes a literal comma. Braces are used rather than a
53
+ // backslash because `\,` is a macro (a thin space) that expands
54
+ // away before this raw argument is ever read.
55
+ const ESCAPED_COMMA = "{,}";
56
+ const data: string[] = [];
57
+ let current = "";
58
+ for (let i = 0; i < value.length; i++) {
59
+ if (value.startsWith(ESCAPED_COMMA, i)) {
60
+ current += ",";
61
+ i += ESCAPED_COMMA.length - 1;
62
+ } else if (value[i] === ",") {
63
+ data.push(current);
64
+ current = "";
65
+ } else {
66
+ current += value[i];
67
+ }
68
+ }
69
+ data.push(current);
53
70
  for (let i = 0; i < data.length; i++) {
54
71
  const item = data[i];
55
72
  const firstEquals = item.indexOf("=");