html-to-markdown-wasm 2.7.0 → 2.7.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
@@ -1,5 +1,8 @@
1
1
  # html-to-markdown-wasm
2
2
 
3
+ > **npm package:** `html-to-markdown-wasm` (this README).
4
+ > Use [`html-to-markdown-node`](https://www.npmjs.com/package/html-to-markdown-node) when you only target Node.js or Bun and want native performance.
5
+
3
6
  Universal HTML to Markdown converter using WebAssembly.
4
7
 
5
8
  Powered by the same Rust engine as the Node.js, Python, Ruby, and PHP bindings, so Markdown output stays identical regardless of runtime.
@@ -38,6 +41,23 @@ Universal WebAssembly bindings with **excellent performance** across all JavaScr
38
41
  - **vs Python**: ~6.3× faster (no FFI overhead)
39
42
  - **Best for**: Universal deployment (browsers, Deno, edge runtimes, cross-platform apps)
40
43
 
44
+ ### Benchmark Fixtures (Apple M4)
45
+
46
+ Numbers captured via `task bench:bindings -- --language wasm` using the shared Wikipedia + hOCR suite:
47
+
48
+ | Document | Size | ops/sec (WASM) |
49
+ | ---------------------- | ------ | -------------- |
50
+ | Lists (Timeline) | 129 KB | 882 |
51
+ | Tables (Countries) | 360 KB | 242 |
52
+ | Medium (Python) | 657 KB | 121 |
53
+ | Large (Rust) | 567 KB | 124 |
54
+ | Small (Intro) | 463 KB | 163 |
55
+ | hOCR German PDF | 44 KB | 1,637 |
56
+ | hOCR Invoice | 4 KB | 7,775 |
57
+ | hOCR Embedded Tables | 37 KB | 1,667 |
58
+
59
+ > Expect slightly higher numbers in long-lived browser/Deno workers once the WASM module is warm.
60
+
41
61
  ## Installation
42
62
 
43
63
  ### npm / Yarn / pnpm
@@ -78,7 +98,7 @@ console.log(markdown);
78
98
  import {
79
99
  convertWithOptionsHandle,
80
100
  createConversionOptionsHandle,
81
- } from '@html-to-markdown/wasm';
101
+ } from 'html-to-markdown-wasm';
82
102
 
83
103
  const handle = createConversionOptionsHandle({ hocrSpatialTables: false });
84
104
  const markdown = convertWithOptionsHandle('<h1>Reusable</h1>', handle);
@@ -94,7 +114,7 @@ import {
94
114
  convertBytesWithOptionsHandle,
95
115
  createConversionOptionsHandle,
96
116
  convertBytesWithInlineImages,
97
- } from '@html-to-markdown/wasm';
117
+ } from 'html-to-markdown-wasm';
98
118
  import { readFileSync } from 'node:fs';
99
119
 
100
120
  const htmlBytes = readFileSync('input.html'); // Buffer -> Uint8Array
@@ -310,7 +330,7 @@ See the [TypeScript definitions](./dist-node/html_to_markdown_wasm.d.ts) for all
310
330
  Keep specific HTML tags in their original form:
311
331
 
312
332
  ```typescript
313
- import { convert } from '@html-to-markdown/wasm';
333
+ import { convert } from 'html-to-markdown-wasm';
314
334
 
315
335
  const html = `
316
336
  <p>Before table</p>
@@ -1,6 +1,8 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
3
4
  export function convertBytes(html: Uint8Array, options: any): string;
5
+ export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
4
6
  /**
5
7
  * Convert HTML to Markdown
6
8
  *
@@ -12,7 +14,7 @@ export function convertBytes(html: Uint8Array, options: any): string;
12
14
  * # Example
13
15
  *
14
16
  * ```javascript
15
- * import { convert } from '@html-to-markdown/wasm';
17
+ * import { convert } from 'html-to-markdown-wasm';
16
18
  *
17
19
  * const html = '<h1>Hello World</h1>';
18
20
  * const markdown = convert(html);
@@ -21,14 +23,12 @@ export function convertBytes(html: Uint8Array, options: any): string;
21
23
  */
22
24
  export function convert(html: string, options: any): string;
23
25
  export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
24
- export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
25
- export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
26
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
26
+ export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
27
27
  /**
28
28
  * Initialize panic hook for better error messages in the browser
29
29
  */
30
30
  export function init(): void;
31
- export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
31
+ export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
32
32
  export class WasmConversionOptionsHandle {
33
33
  free(): void;
34
34
  [Symbol.dispose](): void;
@@ -231,6 +231,39 @@ function getArrayJsValueFromWasm0(ptr, len) {
231
231
  }
232
232
  return result;
233
233
  }
234
+
235
+ function _assertClass(instance, klass) {
236
+ if (!(instance instanceof klass)) {
237
+ throw new Error(`expected instance of ${klass.name}`);
238
+ }
239
+ }
240
+ /**
241
+ * @param {Uint8Array} html
242
+ * @param {any} options
243
+ * @param {WasmInlineImageConfig | null} [image_config]
244
+ * @returns {WasmHtmlExtraction}
245
+ */
246
+ export function convertBytesWithInlineImages(html, options, image_config) {
247
+ try {
248
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
249
+ let ptr0 = 0;
250
+ if (!isLikeNone(image_config)) {
251
+ _assertClass(image_config, WasmInlineImageConfig);
252
+ ptr0 = image_config.__destroy_into_raw();
253
+ }
254
+ wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
255
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
256
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
257
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
258
+ if (r2) {
259
+ throw takeObject(r1);
260
+ }
261
+ return WasmHtmlExtraction.__wrap(r0);
262
+ } finally {
263
+ wasm.__wbindgen_add_to_stack_pointer(16);
264
+ }
265
+ }
266
+
234
267
  /**
235
268
  * @param {Uint8Array} html
236
269
  * @param {any} options
@@ -261,6 +294,26 @@ export function convertBytes(html, options) {
261
294
  }
262
295
  }
263
296
 
297
+ /**
298
+ * @param {any} options
299
+ * @returns {WasmConversionOptionsHandle}
300
+ */
301
+ export function createConversionOptionsHandle(options) {
302
+ try {
303
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
304
+ wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
305
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
306
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
307
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
308
+ if (r2) {
309
+ throw takeObject(r1);
310
+ }
311
+ return WasmConversionOptionsHandle.__wrap(r0);
312
+ } finally {
313
+ wasm.__wbindgen_add_to_stack_pointer(16);
314
+ }
315
+ }
316
+
264
317
  /**
265
318
  * Convert HTML to Markdown
266
319
  *
@@ -272,7 +325,7 @@ export function convertBytes(html, options) {
272
325
  * # Example
273
326
  *
274
327
  * ```javascript
275
- * import { convert } from '@html-to-markdown/wasm';
328
+ * import { convert } from 'html-to-markdown-wasm';
276
329
  *
277
330
  * const html = '<h1>Hello World</h1>';
278
331
  * const markdown = convert(html);
@@ -309,11 +362,6 @@ export function convert(html, options) {
309
362
  }
310
363
  }
311
364
 
312
- function _assertClass(instance, klass) {
313
- if (!(instance instanceof klass)) {
314
- throw new Error(`expected instance of ${klass.name}`);
315
- }
316
- }
317
365
  /**
318
366
  * @param {string} html
319
367
  * @param {WasmConversionOptionsHandle} handle
@@ -348,25 +396,43 @@ export function convertWithOptionsHandle(html, handle) {
348
396
  }
349
397
 
350
398
  /**
351
- * @param {any} options
352
- * @returns {WasmConversionOptionsHandle}
399
+ * @param {Uint8Array} html
400
+ * @param {WasmConversionOptionsHandle} handle
401
+ * @returns {string}
353
402
  */
354
- export function createConversionOptionsHandle(options) {
403
+ export function convertBytesWithOptionsHandle(html, handle) {
404
+ let deferred2_0;
405
+ let deferred2_1;
355
406
  try {
356
407
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
357
- wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
408
+ _assertClass(handle, WasmConversionOptionsHandle);
409
+ wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
358
410
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
359
411
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
360
412
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
361
- if (r2) {
362
- throw takeObject(r1);
413
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
414
+ var ptr1 = r0;
415
+ var len1 = r1;
416
+ if (r3) {
417
+ ptr1 = 0; len1 = 0;
418
+ throw takeObject(r2);
363
419
  }
364
- return WasmConversionOptionsHandle.__wrap(r0);
420
+ deferred2_0 = ptr1;
421
+ deferred2_1 = len1;
422
+ return getStringFromWasm0(ptr1, len1);
365
423
  } finally {
366
424
  wasm.__wbindgen_add_to_stack_pointer(16);
425
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
367
426
  }
368
427
  }
369
428
 
429
+ /**
430
+ * Initialize panic hook for better error messages in the browser
431
+ */
432
+ export function init() {
433
+ wasm.init();
434
+ }
435
+
370
436
  /**
371
437
  * @param {string} html
372
438
  * @param {any} options
@@ -396,71 +462,6 @@ export function convertWithInlineImages(html, options, image_config) {
396
462
  }
397
463
  }
398
464
 
399
- /**
400
- * @param {Uint8Array} html
401
- * @param {any} options
402
- * @param {WasmInlineImageConfig | null} [image_config]
403
- * @returns {WasmHtmlExtraction}
404
- */
405
- export function convertBytesWithInlineImages(html, options, image_config) {
406
- try {
407
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
408
- let ptr0 = 0;
409
- if (!isLikeNone(image_config)) {
410
- _assertClass(image_config, WasmInlineImageConfig);
411
- ptr0 = image_config.__destroy_into_raw();
412
- }
413
- wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
414
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
415
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
416
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
417
- if (r2) {
418
- throw takeObject(r1);
419
- }
420
- return WasmHtmlExtraction.__wrap(r0);
421
- } finally {
422
- wasm.__wbindgen_add_to_stack_pointer(16);
423
- }
424
- }
425
-
426
- /**
427
- * Initialize panic hook for better error messages in the browser
428
- */
429
- export function init() {
430
- wasm.init();
431
- }
432
-
433
- /**
434
- * @param {Uint8Array} html
435
- * @param {WasmConversionOptionsHandle} handle
436
- * @returns {string}
437
- */
438
- export function convertBytesWithOptionsHandle(html, handle) {
439
- let deferred2_0;
440
- let deferred2_1;
441
- try {
442
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
443
- _assertClass(handle, WasmConversionOptionsHandle);
444
- wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
445
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
446
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
447
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
448
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
449
- var ptr1 = r0;
450
- var len1 = r1;
451
- if (r3) {
452
- ptr1 = 0; len1 = 0;
453
- throw takeObject(r2);
454
- }
455
- deferred2_0 = ptr1;
456
- deferred2_1 = len1;
457
- return getStringFromWasm0(ptr1, len1);
458
- } finally {
459
- wasm.__wbindgen_add_to_stack_pointer(16);
460
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
461
- }
462
- }
463
-
464
465
  const WasmConversionOptionsHandleFinalization = (typeof FinalizationRegistry === 'undefined')
465
466
  ? { register: () => {}, unregister: () => {} }
466
467
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmconversionoptionshandle_free(ptr >>> 0, 1));
Binary file
package/dist/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "collaborators": [
5
5
  "Na'aman Hirschfeld <nhirschfeld@gmail.com>"
6
6
  ],
7
- "version": "2.7.0",
7
+ "version": "2.7.1",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",
@@ -1,6 +1,8 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
3
4
  export function convertBytes(html: Uint8Array, options: any): string;
5
+ export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
4
6
  /**
5
7
  * Convert HTML to Markdown
6
8
  *
@@ -12,7 +14,7 @@ export function convertBytes(html: Uint8Array, options: any): string;
12
14
  * # Example
13
15
  *
14
16
  * ```javascript
15
- * import { convert } from '@html-to-markdown/wasm';
17
+ * import { convert } from 'html-to-markdown-wasm';
16
18
  *
17
19
  * const html = '<h1>Hello World</h1>';
18
20
  * const markdown = convert(html);
@@ -21,14 +23,12 @@ export function convertBytes(html: Uint8Array, options: any): string;
21
23
  */
22
24
  export function convert(html: string, options: any): string;
23
25
  export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
24
- export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
25
- export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
26
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
26
+ export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
27
27
  /**
28
28
  * Initialize panic hook for better error messages in the browser
29
29
  */
30
30
  export function init(): void;
31
- export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
31
+ export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
32
32
  export class WasmConversionOptionsHandle {
33
33
  free(): void;
34
34
  [Symbol.dispose](): void;
@@ -221,6 +221,39 @@ function getArrayJsValueFromWasm0(ptr, len) {
221
221
  }
222
222
  return result;
223
223
  }
224
+
225
+ function _assertClass(instance, klass) {
226
+ if (!(instance instanceof klass)) {
227
+ throw new Error(`expected instance of ${klass.name}`);
228
+ }
229
+ }
230
+ /**
231
+ * @param {Uint8Array} html
232
+ * @param {any} options
233
+ * @param {WasmInlineImageConfig | null} [image_config]
234
+ * @returns {WasmHtmlExtraction}
235
+ */
236
+ exports.convertBytesWithInlineImages = function(html, options, image_config) {
237
+ try {
238
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
239
+ let ptr0 = 0;
240
+ if (!isLikeNone(image_config)) {
241
+ _assertClass(image_config, WasmInlineImageConfig);
242
+ ptr0 = image_config.__destroy_into_raw();
243
+ }
244
+ wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
245
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
246
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
247
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
248
+ if (r2) {
249
+ throw takeObject(r1);
250
+ }
251
+ return WasmHtmlExtraction.__wrap(r0);
252
+ } finally {
253
+ wasm.__wbindgen_add_to_stack_pointer(16);
254
+ }
255
+ };
256
+
224
257
  /**
225
258
  * @param {Uint8Array} html
226
259
  * @param {any} options
@@ -251,6 +284,26 @@ exports.convertBytes = function(html, options) {
251
284
  }
252
285
  };
253
286
 
287
+ /**
288
+ * @param {any} options
289
+ * @returns {WasmConversionOptionsHandle}
290
+ */
291
+ exports.createConversionOptionsHandle = function(options) {
292
+ try {
293
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
294
+ wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
295
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
296
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
297
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
298
+ if (r2) {
299
+ throw takeObject(r1);
300
+ }
301
+ return WasmConversionOptionsHandle.__wrap(r0);
302
+ } finally {
303
+ wasm.__wbindgen_add_to_stack_pointer(16);
304
+ }
305
+ };
306
+
254
307
  /**
255
308
  * Convert HTML to Markdown
256
309
  *
@@ -262,7 +315,7 @@ exports.convertBytes = function(html, options) {
262
315
  * # Example
263
316
  *
264
317
  * ```javascript
265
- * import { convert } from '@html-to-markdown/wasm';
318
+ * import { convert } from 'html-to-markdown-wasm';
266
319
  *
267
320
  * const html = '<h1>Hello World</h1>';
268
321
  * const markdown = convert(html);
@@ -299,11 +352,6 @@ exports.convert = function(html, options) {
299
352
  }
300
353
  };
301
354
 
302
- function _assertClass(instance, klass) {
303
- if (!(instance instanceof klass)) {
304
- throw new Error(`expected instance of ${klass.name}`);
305
- }
306
- }
307
355
  /**
308
356
  * @param {string} html
309
357
  * @param {WasmConversionOptionsHandle} handle
@@ -338,25 +386,43 @@ exports.convertWithOptionsHandle = function(html, handle) {
338
386
  };
339
387
 
340
388
  /**
341
- * @param {any} options
342
- * @returns {WasmConversionOptionsHandle}
389
+ * @param {Uint8Array} html
390
+ * @param {WasmConversionOptionsHandle} handle
391
+ * @returns {string}
343
392
  */
344
- exports.createConversionOptionsHandle = function(options) {
393
+ exports.convertBytesWithOptionsHandle = function(html, handle) {
394
+ let deferred2_0;
395
+ let deferred2_1;
345
396
  try {
346
397
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
347
- wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
398
+ _assertClass(handle, WasmConversionOptionsHandle);
399
+ wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
348
400
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
349
401
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
350
402
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
351
- if (r2) {
352
- throw takeObject(r1);
403
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
404
+ var ptr1 = r0;
405
+ var len1 = r1;
406
+ if (r3) {
407
+ ptr1 = 0; len1 = 0;
408
+ throw takeObject(r2);
353
409
  }
354
- return WasmConversionOptionsHandle.__wrap(r0);
410
+ deferred2_0 = ptr1;
411
+ deferred2_1 = len1;
412
+ return getStringFromWasm0(ptr1, len1);
355
413
  } finally {
356
414
  wasm.__wbindgen_add_to_stack_pointer(16);
415
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
357
416
  }
358
417
  };
359
418
 
419
+ /**
420
+ * Initialize panic hook for better error messages in the browser
421
+ */
422
+ exports.init = function() {
423
+ wasm.init();
424
+ };
425
+
360
426
  /**
361
427
  * @param {string} html
362
428
  * @param {any} options
@@ -386,71 +452,6 @@ exports.convertWithInlineImages = function(html, options, image_config) {
386
452
  }
387
453
  };
388
454
 
389
- /**
390
- * @param {Uint8Array} html
391
- * @param {any} options
392
- * @param {WasmInlineImageConfig | null} [image_config]
393
- * @returns {WasmHtmlExtraction}
394
- */
395
- exports.convertBytesWithInlineImages = function(html, options, image_config) {
396
- try {
397
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
398
- let ptr0 = 0;
399
- if (!isLikeNone(image_config)) {
400
- _assertClass(image_config, WasmInlineImageConfig);
401
- ptr0 = image_config.__destroy_into_raw();
402
- }
403
- wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
404
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
405
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
406
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
407
- if (r2) {
408
- throw takeObject(r1);
409
- }
410
- return WasmHtmlExtraction.__wrap(r0);
411
- } finally {
412
- wasm.__wbindgen_add_to_stack_pointer(16);
413
- }
414
- };
415
-
416
- /**
417
- * Initialize panic hook for better error messages in the browser
418
- */
419
- exports.init = function() {
420
- wasm.init();
421
- };
422
-
423
- /**
424
- * @param {Uint8Array} html
425
- * @param {WasmConversionOptionsHandle} handle
426
- * @returns {string}
427
- */
428
- exports.convertBytesWithOptionsHandle = function(html, handle) {
429
- let deferred2_0;
430
- let deferred2_1;
431
- try {
432
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
433
- _assertClass(handle, WasmConversionOptionsHandle);
434
- wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
435
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
436
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
437
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
438
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
439
- var ptr1 = r0;
440
- var len1 = r1;
441
- if (r3) {
442
- ptr1 = 0; len1 = 0;
443
- throw takeObject(r2);
444
- }
445
- deferred2_0 = ptr1;
446
- deferred2_1 = len1;
447
- return getStringFromWasm0(ptr1, len1);
448
- } finally {
449
- wasm.__wbindgen_add_to_stack_pointer(16);
450
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
451
- }
452
- };
453
-
454
455
  const WasmConversionOptionsHandleFinalization = (typeof FinalizationRegistry === 'undefined')
455
456
  ? { register: () => {}, unregister: () => {} }
456
457
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmconversionoptionshandle_free(ptr >>> 0, 1));
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "Na'aman Hirschfeld <nhirschfeld@gmail.com>"
5
5
  ],
6
- "version": "2.7.0",
6
+ "version": "2.7.1",
7
7
  "license": "MIT",
8
8
  "repository": {
9
9
  "type": "git",
@@ -1,6 +1,8 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
3
4
  export function convertBytes(html: Uint8Array, options: any): string;
5
+ export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
4
6
  /**
5
7
  * Convert HTML to Markdown
6
8
  *
@@ -12,7 +14,7 @@ export function convertBytes(html: Uint8Array, options: any): string;
12
14
  * # Example
13
15
  *
14
16
  * ```javascript
15
- * import { convert } from '@html-to-markdown/wasm';
17
+ * import { convert } from 'html-to-markdown-wasm';
16
18
  *
17
19
  * const html = '<h1>Hello World</h1>';
18
20
  * const markdown = convert(html);
@@ -21,14 +23,12 @@ export function convertBytes(html: Uint8Array, options: any): string;
21
23
  */
22
24
  export function convert(html: string, options: any): string;
23
25
  export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
24
- export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
25
- export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
26
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
26
+ export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
27
27
  /**
28
28
  * Initialize panic hook for better error messages in the browser
29
29
  */
30
30
  export function init(): void;
31
- export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
31
+ export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
32
32
  export class WasmConversionOptionsHandle {
33
33
  free(): void;
34
34
  [Symbol.dispose](): void;
@@ -227,6 +227,39 @@ function getArrayJsValueFromWasm0(ptr, len) {
227
227
  }
228
228
  return result;
229
229
  }
230
+
231
+ function _assertClass(instance, klass) {
232
+ if (!(instance instanceof klass)) {
233
+ throw new Error(`expected instance of ${klass.name}`);
234
+ }
235
+ }
236
+ /**
237
+ * @param {Uint8Array} html
238
+ * @param {any} options
239
+ * @param {WasmInlineImageConfig | null} [image_config]
240
+ * @returns {WasmHtmlExtraction}
241
+ */
242
+ export function convertBytesWithInlineImages(html, options, image_config) {
243
+ try {
244
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
245
+ let ptr0 = 0;
246
+ if (!isLikeNone(image_config)) {
247
+ _assertClass(image_config, WasmInlineImageConfig);
248
+ ptr0 = image_config.__destroy_into_raw();
249
+ }
250
+ wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
251
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
252
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
253
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
254
+ if (r2) {
255
+ throw takeObject(r1);
256
+ }
257
+ return WasmHtmlExtraction.__wrap(r0);
258
+ } finally {
259
+ wasm.__wbindgen_add_to_stack_pointer(16);
260
+ }
261
+ }
262
+
230
263
  /**
231
264
  * @param {Uint8Array} html
232
265
  * @param {any} options
@@ -257,6 +290,26 @@ export function convertBytes(html, options) {
257
290
  }
258
291
  }
259
292
 
293
+ /**
294
+ * @param {any} options
295
+ * @returns {WasmConversionOptionsHandle}
296
+ */
297
+ export function createConversionOptionsHandle(options) {
298
+ try {
299
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
300
+ wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
301
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
302
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
303
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
304
+ if (r2) {
305
+ throw takeObject(r1);
306
+ }
307
+ return WasmConversionOptionsHandle.__wrap(r0);
308
+ } finally {
309
+ wasm.__wbindgen_add_to_stack_pointer(16);
310
+ }
311
+ }
312
+
260
313
  /**
261
314
  * Convert HTML to Markdown
262
315
  *
@@ -268,7 +321,7 @@ export function convertBytes(html, options) {
268
321
  * # Example
269
322
  *
270
323
  * ```javascript
271
- * import { convert } from '@html-to-markdown/wasm';
324
+ * import { convert } from 'html-to-markdown-wasm';
272
325
  *
273
326
  * const html = '<h1>Hello World</h1>';
274
327
  * const markdown = convert(html);
@@ -305,11 +358,6 @@ export function convert(html, options) {
305
358
  }
306
359
  }
307
360
 
308
- function _assertClass(instance, klass) {
309
- if (!(instance instanceof klass)) {
310
- throw new Error(`expected instance of ${klass.name}`);
311
- }
312
- }
313
361
  /**
314
362
  * @param {string} html
315
363
  * @param {WasmConversionOptionsHandle} handle
@@ -344,25 +392,43 @@ export function convertWithOptionsHandle(html, handle) {
344
392
  }
345
393
 
346
394
  /**
347
- * @param {any} options
348
- * @returns {WasmConversionOptionsHandle}
395
+ * @param {Uint8Array} html
396
+ * @param {WasmConversionOptionsHandle} handle
397
+ * @returns {string}
349
398
  */
350
- export function createConversionOptionsHandle(options) {
399
+ export function convertBytesWithOptionsHandle(html, handle) {
400
+ let deferred2_0;
401
+ let deferred2_1;
351
402
  try {
352
403
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
353
- wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
404
+ _assertClass(handle, WasmConversionOptionsHandle);
405
+ wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
354
406
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
355
407
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
356
408
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
357
- if (r2) {
358
- throw takeObject(r1);
409
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
410
+ var ptr1 = r0;
411
+ var len1 = r1;
412
+ if (r3) {
413
+ ptr1 = 0; len1 = 0;
414
+ throw takeObject(r2);
359
415
  }
360
- return WasmConversionOptionsHandle.__wrap(r0);
416
+ deferred2_0 = ptr1;
417
+ deferred2_1 = len1;
418
+ return getStringFromWasm0(ptr1, len1);
361
419
  } finally {
362
420
  wasm.__wbindgen_add_to_stack_pointer(16);
421
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
363
422
  }
364
423
  }
365
424
 
425
+ /**
426
+ * Initialize panic hook for better error messages in the browser
427
+ */
428
+ export function init() {
429
+ wasm.init();
430
+ }
431
+
366
432
  /**
367
433
  * @param {string} html
368
434
  * @param {any} options
@@ -392,71 +458,6 @@ export function convertWithInlineImages(html, options, image_config) {
392
458
  }
393
459
  }
394
460
 
395
- /**
396
- * @param {Uint8Array} html
397
- * @param {any} options
398
- * @param {WasmInlineImageConfig | null} [image_config]
399
- * @returns {WasmHtmlExtraction}
400
- */
401
- export function convertBytesWithInlineImages(html, options, image_config) {
402
- try {
403
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
404
- let ptr0 = 0;
405
- if (!isLikeNone(image_config)) {
406
- _assertClass(image_config, WasmInlineImageConfig);
407
- ptr0 = image_config.__destroy_into_raw();
408
- }
409
- wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
410
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
411
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
412
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
413
- if (r2) {
414
- throw takeObject(r1);
415
- }
416
- return WasmHtmlExtraction.__wrap(r0);
417
- } finally {
418
- wasm.__wbindgen_add_to_stack_pointer(16);
419
- }
420
- }
421
-
422
- /**
423
- * Initialize panic hook for better error messages in the browser
424
- */
425
- export function init() {
426
- wasm.init();
427
- }
428
-
429
- /**
430
- * @param {Uint8Array} html
431
- * @param {WasmConversionOptionsHandle} handle
432
- * @returns {string}
433
- */
434
- export function convertBytesWithOptionsHandle(html, handle) {
435
- let deferred2_0;
436
- let deferred2_1;
437
- try {
438
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
439
- _assertClass(handle, WasmConversionOptionsHandle);
440
- wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
441
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
442
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
443
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
444
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
445
- var ptr1 = r0;
446
- var len1 = r1;
447
- if (r3) {
448
- ptr1 = 0; len1 = 0;
449
- throw takeObject(r2);
450
- }
451
- deferred2_0 = ptr1;
452
- deferred2_1 = len1;
453
- return getStringFromWasm0(ptr1, len1);
454
- } finally {
455
- wasm.__wbindgen_add_to_stack_pointer(16);
456
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
457
- }
458
- }
459
-
460
461
  const WasmConversionOptionsHandleFinalization = (typeof FinalizationRegistry === 'undefined')
461
462
  ? { register: () => {}, unregister: () => {} }
462
463
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmconversionoptionshandle_free(ptr >>> 0, 1));
@@ -4,7 +4,7 @@
4
4
  "collaborators": [
5
5
  "Na'aman Hirschfeld <nhirschfeld@gmail.com>"
6
6
  ],
7
- "version": "2.7.0",
7
+ "version": "2.7.1",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-to-markdown-wasm",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "description": "High-performance HTML to Markdown converter - WebAssembly bindings",
5
5
  "main": "dist/html_to_markdown_wasm.js",
6
6
  "types": "dist/html_to_markdown_wasm.d.ts",