math-core 0.6.4 → 0.8.1

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/README.md CHANGED
@@ -12,6 +12,7 @@ A Node.js library for converting LaTeX math expressions to MathML Core.
12
12
  - Support for both inline and display (block) math
13
13
  - Define custom LaTeX macros for extended functionality
14
14
  - Global and local counter for numbered equations
15
+ - Batch conversion which resolves forward references between snippets
15
16
  - Pretty-printing option for readable MathML output
16
17
  - Comprehensive error handling with descriptive error messages
17
18
 
@@ -31,12 +32,12 @@ import { LatexToMathML } from "math-core";
31
32
  const converter = new LatexToMathML({});
32
33
 
33
34
  // Convert inline math
34
- const inline = converter.convert_with_local_counter("x^2 + y^2 = z^2", false);
35
+ const inline = converter.convert_with_local_state("x^2 + y^2 = z^2", false);
35
36
  console.log(inline);
36
37
  // Output: <math><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><msup><mi>y</mi><mn>2</mn></msup><mo>=</mo><msup><mi>z</mi><mn>2</mn></msup></math>
37
38
 
38
39
  // Convert display math
39
- const display = converter.convert_with_local_counter("\\frac{1}{2}", true);
40
+ const display = converter.convert_with_local_state("\\frac{1}{2}", true);
40
41
  console.log(display);
41
42
  // Output: <math display="block"><mfrac><mn>1</mn><mn>2</mn></mfrac></math>
42
43
  ```
@@ -51,7 +52,7 @@ import { LatexToMathML } from "math-core";
51
52
  const converter = new LatexToMathML({ prettyPrint: "always" });
52
53
 
53
54
  try {
54
- const mathml = converter.convert_with_local_counter("\\sqrt{x^2 + 1}", false);
55
+ const mathml = converter.convert_with_local_state("\\sqrt{x^2 + 1}", false);
55
56
  console.log(mathml);
56
57
  } catch (e) {
57
58
  console.error(`Conversion error: ${e.message}`);
@@ -69,10 +70,10 @@ macros.set("R", "\\mathbb{R}"); // Real numbers
69
70
  macros.set("vec", "\\mathbf{#1}"); // Vector notation
70
71
 
71
72
  const converter = new LatexToMathML({ macros });
72
- const mathml = converter.convert_with_local_counter("\\d x", false);
73
+ const mathml = converter.convert_with_local_state("\\d x", false);
73
74
  ```
74
75
 
75
- ### Numbered Equations with Global Counter
76
+ ### Numbered Equations with Global State
76
77
 
77
78
  For documents with multiple numbered equations:
78
79
 
@@ -80,22 +81,22 @@ For documents with multiple numbered equations:
80
81
  const converter = new LatexToMathML({});
81
82
 
82
83
  // First equation gets (1)
83
- const eq1 = converter.convert_with_global_counter(
84
+ const eq1 = converter.convert_with_global_state(
84
85
  "\\begin{align}E = mc^2\\end{align}",
85
86
  true,
86
87
  );
87
88
 
88
89
  // Second equation gets (2)
89
- const eq2 = converter.convert_with_global_counter(
90
+ const eq2 = converter.convert_with_global_state(
90
91
  "\\begin{align}F = ma\\end{align}",
91
92
  true,
92
93
  );
93
94
 
94
95
  // Reset counter when starting a new chapter/section
95
- converter.reset_global_counter();
96
+ converter.reset_global_state();
96
97
 
97
98
  // This equation gets (1) again
98
- const eq3 = converter.convert_with_global_counter(
99
+ const eq3 = converter.convert_with_global_state(
99
100
  "\\begin{align}p = mv\\end{align}",
100
101
  true,
101
102
  );
@@ -109,17 +110,39 @@ Use local counters when equation numbers should restart within each conversion:
109
110
  const converter = new LatexToMathML({});
110
111
 
111
112
  // Each conversion has independent numbering
112
- const doc1 = converter.convert_with_local_counter(
113
+ const doc1 = converter.convert_with_local_state(
113
114
  "\\begin{align}a &= b\\\\c &= d\\end{align}",
114
115
  true,
115
116
  ); // Contains (1) and (2)
116
117
 
117
- const doc2 = converter.convert_with_local_counter(
118
+ const doc2 = converter.convert_with_local_state(
118
119
  "\\begin{align}x &= y\\\\z &= w\\end{align}",
119
120
  true,
120
121
  ); // Also contains (1) and (2)
121
122
  ```
122
123
 
124
+ ### Converting a Whole Document at Once
125
+
126
+ `convert_all` converts a collection of snippets in one go, which is the only way to get
127
+ *forward references* right: a snippet may refer to an equation which is only defined in a later
128
+ snippet.
129
+
130
+ ```javascript
131
+ const converter = new LatexToMathML({});
132
+
133
+ const [reference, equation] = converter.convert_all([
134
+ { latex: "\\eqref{eq:euler}", displayStyle: false },
135
+ {
136
+ latex: "\\begin{align}e^{i\\pi} + 1 = 0\\label{eq:euler}\\end{align}",
137
+ displayStyle: true,
138
+ },
139
+ ]);
140
+ // `reference` refers to equation (1), even though it comes first.
141
+ ```
142
+
143
+ Equation numbering restarts with every call to `convert_all`; the state of
144
+ `convert_with_global_state` is neither used nor modified.
145
+
123
146
  ### Error Handling
124
147
 
125
148
  By default, conversion errors throw a `LatexError` with detailed diagnostics:
@@ -128,7 +151,7 @@ By default, conversion errors throw a `LatexError` with detailed diagnostics:
128
151
  const converter = new LatexToMathML({});
129
152
 
130
153
  try {
131
- converter.convert_with_local_counter("\\begin{foobar}", false);
154
+ converter.convert_with_local_state("\\begin{foobar}", false);
132
155
  } catch (e) {
133
156
  console.log(e.message); // 'Unknown environment "foobar".'
134
157
  console.log(e.report); // Formatted diagnostic with source spans
@@ -142,7 +165,7 @@ Set `throwOnError: false` to return an HTML error snippet instead of throwing:
142
165
 
143
166
  ```javascript
144
167
  const converter = new LatexToMathML({ throwOnError: false });
145
- const result = converter.convert_with_local_counter("\\invalid", false);
168
+ const result = converter.convert_with_local_state("\\invalid", false);
146
169
  // Returns: <span class="math-core-error" title="..."><code>\invalid</code></span>
147
170
  ```
148
171
 
@@ -168,12 +191,16 @@ new LatexToMathML(options: MathCoreOptions)
168
191
  | `throwOnError` | `boolean` | `true` | Throw `LatexError` on conversion errors. If `false`, returns an HTML error snippet instead. |
169
192
  | `ignoreUnknownCommands` | `boolean` | `false` | Render unknown commands as red text instead of erroring. |
170
193
  | `annotation` | `boolean` | `false` | Include the original LaTeX as an annotation in the MathML output. |
194
+ | `globalGroup` | `boolean` | `false` | Run the conversion in the global group, so that commands defined with `\newcommand` stay defined for subsequent calls to `convert_with_global_state`. If `false`, such definitions are local to the snippet which contains them. |
195
+ | `maxExpansions` | `number` | `1000` | How many custom commands may be expanded in one snippet before the conversion gives up. The limit exists because a macro may expand to itself, directly or indirectly. |
196
+ | `idPrefix` | `string` | `""` | Added to the beginning of every `id` and anchor reference. Use this to avoid conflicts when embedding the output. |
171
197
 
172
198
  **Methods:**
173
199
 
174
- - `convert_with_global_counter(latex: string, displaystyle: boolean): string` — Convert LaTeX to MathML using a global equation counter.
175
- - `convert_with_local_counter(latex: string, displaystyle: boolean): string` — Convert LaTeX to MathML using a local equation counter.
176
- - `reset_global_counter(): void` — Reset the global equation counter to zero.
200
+ - `convert_with_global_state(latex: string, displaystyle: boolean): string` — Convert LaTeX to MathML using global state.
201
+ - `convert_with_local_state(latex: string, displaystyle: boolean): string` — Convert LaTeX to MathML using local state.
202
+ - `convert_all(snippets: MathSnippet[]): string[]` — Convert all snippets of a document at once, resolving forward references between them. A `MathSnippet` is `{ latex: string, displayStyle: boolean }`. Uses a fresh state for the batch, independent of the global state.
203
+ - `reset_global_state(): void` — Reset the global state (e.g., set the equation counter to zero).
177
204
 
178
205
  ### `LatexError`
179
206
 
@@ -188,6 +215,7 @@ Error thrown when LaTeX parsing or conversion fails.
188
215
  | `context` | `string \| undefined` | The relevant LaTeX source. |
189
216
  | `start` | `number` | Start offset of the error in the source. |
190
217
  | `end` | `number` | End offset of the error in the source. |
218
+ | `index` | `number \| undefined` | Index of the failing snippet; only set by `convert_all`. |
191
219
 
192
220
  ## Why MathML Core?
193
221
 
@@ -9,6 +9,15 @@ interface MathCoreOptions {
9
9
  ignoreUnknownCommands?: boolean;
10
10
  annotation?: boolean;
11
11
  allowUnreliableRendering?: boolean;
12
+ globalGroup?: boolean;
13
+ unicodeSubstitution?: "never" | "conventional";
14
+ maxExpansions?: number;
15
+ idPrefix?: string;
16
+ }
17
+
18
+ interface MathSnippet {
19
+ latex: string;
20
+ displayStyle: boolean;
12
21
  }
13
22
 
14
23
 
@@ -25,6 +34,14 @@ export class LatexError {
25
34
  free(): void;
26
35
  [Symbol.dispose](): void;
27
36
  end: number;
37
+ /**
38
+ * The index of the snippet that caused the error; only set by `convert_all`.
39
+ */
40
+ get index(): number | undefined;
41
+ /**
42
+ * The index of the snippet that caused the error; only set by `convert_all`.
43
+ */
44
+ set index(value: number | null | undefined);
28
45
  start: number;
29
46
  readonly context: string | undefined;
30
47
  readonly label: string;
@@ -35,8 +52,18 @@ export class LatexError {
35
52
  export class LatexToMathML {
36
53
  free(): void;
37
54
  [Symbol.dispose](): void;
38
- convert_with_global_counter(content: string, displaystyle: boolean): string;
39
- convert_with_local_counter(content: string, displaystyle: boolean): string;
55
+ /**
56
+ * Convert a collection of LaTeX snippets to MathML.
57
+ *
58
+ * In contrast to the other conversion methods, this one resolves *forward references*
59
+ * correctly, meaning that a snippet can refer to an equation which is only defined in a
60
+ * later snippet. This is why all snippets of a document have to be passed in at once.
61
+ *
62
+ * The conversion does not touch the global state; it uses a fresh state for the whole batch.
63
+ */
64
+ convert_all(snippets: MathSnippet[]): string[];
65
+ convert_with_global_state(content: string, displaystyle: boolean): string;
66
+ convert_with_local_state(content: string, displaystyle: boolean): string;
40
67
  constructor(js_config: MathCoreOptions);
41
- reset_global_counter(): void;
68
+ reset_global_state(): void;
42
69
  }
package/dist/math_core.js CHANGED
@@ -53,6 +53,14 @@ export class LatexError {
53
53
  const ret = wasm.__wbg_get_latexerror_end(this.__wbg_ptr);
54
54
  return ret >>> 0;
55
55
  }
56
+ /**
57
+ * The index of the snippet that caused the error; only set by `convert_all`.
58
+ * @returns {number | undefined}
59
+ */
60
+ get index() {
61
+ const ret = wasm.__wbg_get_latexerror_index(this.__wbg_ptr);
62
+ return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
63
+ }
56
64
  /**
57
65
  * @returns {number}
58
66
  */
@@ -94,6 +102,13 @@ export class LatexError {
94
102
  set end(arg0) {
95
103
  wasm.__wbg_set_latexerror_end(this.__wbg_ptr, arg0);
96
104
  }
105
+ /**
106
+ * The index of the snippet that caused the error; only set by `convert_all`.
107
+ * @param {number | null} [arg0]
108
+ */
109
+ set index(arg0) {
110
+ wasm.__wbg_set_latexerror_index(this.__wbg_ptr, isLikeNone(arg0) ? Number.MAX_SAFE_INTEGER : (arg0) >>> 0);
111
+ }
97
112
  /**
98
113
  * @param {number} arg0
99
114
  */
@@ -114,15 +129,35 @@ export class LatexToMathML {
114
129
  const ptr = this.__destroy_into_raw();
115
130
  wasm.__wbg_latextomathml_free(ptr, 0);
116
131
  }
132
+ /**
133
+ * Convert a collection of LaTeX snippets to MathML.
134
+ *
135
+ * In contrast to the other conversion methods, this one resolves *forward references*
136
+ * correctly, meaning that a snippet can refer to an equation which is only defined in a
137
+ * later snippet. This is why all snippets of a document have to be passed in at once.
138
+ *
139
+ * The conversion does not touch the global state; it uses a fresh state for the whole batch.
140
+ * @param {MathSnippet[]} snippets
141
+ * @returns {string[]}
142
+ */
143
+ convert_all(snippets) {
144
+ const ptr0 = passArrayJsValueToWasm0(snippets, wasm.__wbindgen_malloc);
145
+ const len0 = WASM_VECTOR_LEN;
146
+ const ret = wasm.latextomathml_convert_all(this.__wbg_ptr, ptr0, len0);
147
+ if (ret[2]) {
148
+ throw takeFromExternrefTable0(ret[1]);
149
+ }
150
+ return takeFromExternrefTable0(ret[0]);
151
+ }
117
152
  /**
118
153
  * @param {string} content
119
154
  * @param {boolean} displaystyle
120
155
  * @returns {string}
121
156
  */
122
- convert_with_global_counter(content, displaystyle) {
157
+ convert_with_global_state(content, displaystyle) {
123
158
  const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
124
159
  const len0 = WASM_VECTOR_LEN;
125
- const ret = wasm.latextomathml_convert_with_global_counter(this.__wbg_ptr, ptr0, len0, displaystyle);
160
+ const ret = wasm.latextomathml_convert_with_global_state(this.__wbg_ptr, ptr0, len0, displaystyle);
126
161
  if (ret[2]) {
127
162
  throw takeFromExternrefTable0(ret[1]);
128
163
  }
@@ -133,10 +168,10 @@ export class LatexToMathML {
133
168
  * @param {boolean} displaystyle
134
169
  * @returns {string}
135
170
  */
136
- convert_with_local_counter(content, displaystyle) {
171
+ convert_with_local_state(content, displaystyle) {
137
172
  const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
138
173
  const len0 = WASM_VECTOR_LEN;
139
- const ret = wasm.latextomathml_convert_with_local_counter(this.__wbg_ptr, ptr0, len0, displaystyle);
174
+ const ret = wasm.latextomathml_convert_with_local_state(this.__wbg_ptr, ptr0, len0, displaystyle);
140
175
  if (ret[2]) {
141
176
  throw takeFromExternrefTable0(ret[1]);
142
177
  }
@@ -154,15 +189,15 @@ export class LatexToMathML {
154
189
  LatexToMathMLFinalization.register(this, this.__wbg_ptr, this);
155
190
  return this;
156
191
  }
157
- reset_global_counter() {
158
- wasm.latextomathml_reset_global_counter(this.__wbg_ptr);
192
+ reset_global_state() {
193
+ wasm.latextomathml_reset_global_state(this.__wbg_ptr);
159
194
  }
160
195
  }
161
196
  if (Symbol.dispose) LatexToMathML.prototype[Symbol.dispose] = LatexToMathML.prototype.free;
162
197
  function __wbg_get_imports() {
163
198
  const import0 = {
164
199
  __proto__: null,
165
- __wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
200
+ __wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
166
201
  const obj = arg1;
167
202
  const ret = typeof(obj) === 'string' ? obj : undefined;
168
203
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -170,14 +205,14 @@ function __wbg_get_imports() {
170
205
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
171
206
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
172
207
  },
173
- __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
208
+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
174
209
  throw new Error(getStringFromWasm0(arg0, arg1));
175
210
  },
176
- __wbg_allowUnreliableRendering_85799e8d6aea3b13: function(arg0) {
211
+ __wbg_allowUnreliableRendering_f0c78f4923af73fc: function(arg0) {
177
212
  const ret = arg0.allowUnreliableRendering;
178
213
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
179
214
  },
180
- __wbg_annotation_787a5a6d7b450089: function(arg0) {
215
+ __wbg_annotation_219e13c187863cec: function(arg0) {
181
216
  const ret = arg0.annotation;
182
217
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
183
218
  },
@@ -185,58 +220,91 @@ function __wbg_get_imports() {
185
220
  const ret = ConfigParseError.__wrap(arg0);
186
221
  return ret;
187
222
  },
188
- __wbg_done_60cf307fcc680536: function(arg0) {
223
+ __wbg_displayStyle_ef5256c58c97a5f4: function(arg0) {
224
+ const ret = arg0.displayStyle;
225
+ return ret;
226
+ },
227
+ __wbg_done_669171204c3dcae2: function(arg0) {
189
228
  const ret = arg0.done;
190
229
  return ret;
191
230
  },
192
- __wbg_entries_206899f1a3dd30a8: function(arg0) {
231
+ __wbg_entries_71601bcb707d5078: function(arg0) {
193
232
  const ret = arg0.entries();
194
233
  return ret;
195
234
  },
196
- __wbg_get_2b48c7d0d006a781: function(arg0, arg1) {
235
+ __wbg_get_c0c8f8d7da0c03dd: function(arg0, arg1) {
197
236
  const ret = arg0[arg1 >>> 0];
198
237
  return ret;
199
238
  },
200
- __wbg_ignoreUnknownCommands_2e5f9e0782e159a4: function(arg0) {
239
+ __wbg_globalGroup_417d1d431020809d: function(arg0) {
240
+ const ret = arg0.globalGroup;
241
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
242
+ },
243
+ __wbg_idPrefix_07be803c89cf3933: function(arg0, arg1) {
244
+ const ret = arg1.idPrefix;
245
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
246
+ var len1 = WASM_VECTOR_LEN;
247
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
248
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
249
+ },
250
+ __wbg_ignoreUnknownCommands_da90e0b44c9174eb: function(arg0) {
201
251
  const ret = arg0.ignoreUnknownCommands;
202
252
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
203
253
  },
204
- __wbg_isArray_67c2c9c4313f4448: function(arg0) {
254
+ __wbg_isArray_6339f732981044bf: function(arg0) {
205
255
  const ret = Array.isArray(arg0);
206
256
  return ret;
207
257
  },
258
+ __wbg_latex_1391c6fb0158a049: function(arg0, arg1) {
259
+ const ret = arg1.latex;
260
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
261
+ const len1 = WASM_VECTOR_LEN;
262
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
263
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
264
+ },
208
265
  __wbg_latexerror_new: function(arg0) {
209
266
  const ret = LatexError.__wrap(arg0);
210
267
  return ret;
211
268
  },
212
- __wbg_macros_b577b47d3bca5e4c: function(arg0) {
269
+ __wbg_macros_8b80b019c07a1eea: function(arg0) {
213
270
  const ret = arg0.macros;
214
271
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
215
272
  },
216
- __wbg_next_eb8ca7351fa27906: function() { return handleError(function (arg0) {
273
+ __wbg_maxExpansions_16e5fe2a6d81c63d: function(arg0) {
274
+ const ret = arg0.maxExpansions;
275
+ return isLikeNone(ret) ? Number.MAX_SAFE_INTEGER : (ret) >>> 0;
276
+ },
277
+ __wbg_next_42cf16ee0dafc9e2: function() { return handleError(function (arg0) {
217
278
  const ret = arg0.next();
218
279
  return ret;
219
280
  }, arguments); },
220
- __wbg_prettyPrint_3bde870ba3a210c7: function(arg0, arg1) {
281
+ __wbg_prettyPrint_5d11563071318855: function(arg0, arg1) {
221
282
  const ret = arg1.prettyPrint;
222
283
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
223
284
  var len1 = WASM_VECTOR_LEN;
224
285
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
225
286
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
226
287
  },
227
- __wbg_size_5ef6bbbc4b6332a9: function(arg0) {
288
+ __wbg_size_7c5f5d6c17503441: function(arg0) {
228
289
  const ret = arg0.size;
229
290
  return ret;
230
291
  },
231
- __wbg_throwOnError_f0f4b6c0a179492b: function(arg0) {
292
+ __wbg_throwOnError_1c2db037b7b92155: function(arg0) {
232
293
  const ret = arg0.throwOnError;
233
294
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
234
295
  },
235
- __wbg_value_f3625092ee4b37f4: function(arg0) {
296
+ __wbg_unicodeSubstitution_ef25a02b6746022e: function(arg0, arg1) {
297
+ const ret = arg1.unicodeSubstitution;
298
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
299
+ var len1 = WASM_VECTOR_LEN;
300
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
301
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
302
+ },
303
+ __wbg_value_1e2369fab29b420e: function(arg0) {
236
304
  const ret = arg0.value;
237
305
  return ret;
238
306
  },
239
- __wbg_xmlNamespace_64127331da9c1367: function(arg0) {
307
+ __wbg_xmlNamespace_58e49416ebc58362: function(arg0) {
240
308
  const ret = arg0.xmlNamespace;
241
309
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
242
310
  },
@@ -245,6 +313,13 @@ function __wbg_get_imports() {
245
313
  const ret = getStringFromWasm0(arg0, arg1);
246
314
  return ret;
247
315
  },
316
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
317
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1);
318
+ wasm.__wbindgen_free(arg0, arg1 * 4, 4);
319
+ // Cast intrinsic for `Vector(Externref) -> Externref`.
320
+ const ret = v0;
321
+ return ret;
322
+ },
248
323
  __wbindgen_init_externref_table: function() {
249
324
  const table = wasm.__wbindgen_externrefs;
250
325
  const offset = table.grow(4);
@@ -277,6 +352,17 @@ function addToExternrefTable0(obj) {
277
352
  return idx;
278
353
  }
279
354
 
355
+ function getArrayJsValueFromWasm0(ptr, len) {
356
+ ptr = ptr >>> 0;
357
+ const mem = getDataViewMemory0();
358
+ const result = [];
359
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
360
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
361
+ }
362
+ wasm.__externref_drop_slice(ptr, len);
363
+ return result;
364
+ }
365
+
280
366
  let cachedDataViewMemory0 = null;
281
367
  function getDataViewMemory0() {
282
368
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
@@ -310,6 +396,16 @@ function isLikeNone(x) {
310
396
  return x === undefined || x === null;
311
397
  }
312
398
 
399
+ function passArrayJsValueToWasm0(array, malloc) {
400
+ const ptr = malloc(array.length * 4, 4) >>> 0;
401
+ for (let i = 0; i < array.length; i++) {
402
+ const add = addToExternrefTable0(array[i]);
403
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
404
+ }
405
+ WASM_VECTOR_LEN = array.length;
406
+ return ptr;
407
+ }
408
+
313
409
  function passStringToWasm0(arg, malloc, realloc) {
314
410
  if (realloc === undefined) {
315
411
  const buf = cachedTextEncoder.encode(arg);
Binary file
@@ -3,24 +3,29 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_configparseerror_free: (a: number, b: number) => void;
5
5
  export const __wbg_get_latexerror_end: (a: number) => number;
6
+ export const __wbg_get_latexerror_index: (a: number) => number;
6
7
  export const __wbg_get_latexerror_start: (a: number) => number;
7
8
  export const __wbg_latexerror_free: (a: number, b: number) => void;
8
9
  export const __wbg_latextomathml_free: (a: number, b: number) => void;
9
10
  export const __wbg_set_latexerror_end: (a: number, b: number) => void;
11
+ export const __wbg_set_latexerror_index: (a: number, b: number) => void;
10
12
  export const __wbg_set_latexerror_start: (a: number, b: number) => void;
11
13
  export const configparseerror_message: (a: number) => any;
12
14
  export const latexerror_context: (a: number) => any;
13
15
  export const latexerror_label: (a: number) => any;
14
16
  export const latexerror_message: (a: number) => any;
15
17
  export const latexerror_report: (a: number) => any;
16
- export const latextomathml_convert_with_global_counter: (a: number, b: number, c: number, d: number) => [number, number, number];
17
- export const latextomathml_convert_with_local_counter: (a: number, b: number, c: number, d: number) => [number, number, number];
18
+ export const latextomathml_convert_all: (a: number, b: number, c: number) => [number, number, number];
19
+ export const latextomathml_convert_with_global_state: (a: number, b: number, c: number, d: number) => [number, number, number];
20
+ export const latextomathml_convert_with_local_state: (a: number, b: number, c: number, d: number) => [number, number, number];
18
21
  export const latextomathml_new: (a: any) => [number, number, number];
19
- export const latextomathml_reset_global_counter: (a: number) => void;
22
+ export const latextomathml_reset_global_state: (a: number) => void;
20
23
  export const __wbindgen_malloc: (a: number, b: number) => number;
21
24
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
22
25
  export const __externref_table_alloc: () => number;
23
26
  export const __wbindgen_externrefs: WebAssembly.Table;
24
27
  export const __wbindgen_exn_store: (a: number) => void;
28
+ export const __externref_drop_slice: (a: number, b: number) => void;
29
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
25
30
  export const __externref_table_dealloc: (a: number) => void;
26
31
  export const __wbindgen_start: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-core",
3
- "version": "0.6.4",
3
+ "version": "0.8.1",
4
4
  "description": "Convert LaTeX to MathML Core",
5
5
  "homepage": "https://github.com/tmke8/math-core#readme",
6
6
  "bugs": {