html-to-markdown-wasm 2.8.3 → 2.9.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
@@ -15,7 +15,7 @@ Runs anywhere: Node.js, Deno, Bun, browsers, and edge runtimes.
15
15
  [![PyPI](https://badge.fury.io/py/html-to-markdown.svg)](https://pypi.org/project/html-to-markdown/)
16
16
  [![Packagist](https://img.shields.io/packagist/v/goldziher/html-to-markdown.svg)](https://packagist.org/packages/goldziher/html-to-markdown)
17
17
  [![RubyGems](https://badge.fury.io/rb/html-to-markdown.svg)](https://rubygems.org/gems/html-to-markdown)
18
- [![NuGet](https://img.shields.io/nuget/v/HtmlToMarkdown.svg)](https://www.nuget.org/packages/HtmlToMarkdown/)
18
+ [![NuGet](https://img.shields.io/nuget/v/Goldziher.HtmlToMarkdown.svg)](https://www.nuget.org/packages/Goldziher.HtmlToMarkdown/)
19
19
  [![Maven Central](https://img.shields.io/maven-central/v/io.github.goldziher/html-to-markdown.svg)](https://central.sonatype.com/artifact/io.github.goldziher/html-to-markdown)
20
20
  [![Go Reference](https://pkg.go.dev/badge/github.com/Goldziher/html-to-markdown/packages/go/htmltomarkdown.svg)](https://pkg.go.dev/github.com/Goldziher/html-to-markdown/packages/go/htmltomarkdown)
21
21
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Goldziher/html-to-markdown/blob/main/LICENSE)
package/dist/README.md CHANGED
@@ -9,7 +9,7 @@ High-performance HTML → Markdown conversion powered by Rust. Shipping as a Rus
9
9
  [![Packagist](https://img.shields.io/packagist/v/goldziher/html-to-markdown.svg)](https://packagist.org/packages/goldziher/html-to-markdown)
10
10
  [![RubyGems](https://badge.fury.io/rb/html-to-markdown.svg)](https://rubygems.org/gems/html-to-markdown)
11
11
  [![Hex.pm](https://img.shields.io/hexpm/v/html_to_markdown.svg)](https://hex.pm/packages/html_to_markdown)
12
- [![NuGet](https://img.shields.io/nuget/v/HtmlToMarkdown.svg)](https://www.nuget.org/packages/HtmlToMarkdown/)
12
+ [![NuGet](https://img.shields.io/nuget/v/Goldziher.HtmlToMarkdown.svg)](https://www.nuget.org/packages/Goldziher.HtmlToMarkdown/)
13
13
  [![Maven Central](https://img.shields.io/maven-central/v/io.github.goldziher/html-to-markdown.svg)](https://central.sonatype.com/artifact/io.github.goldziher/html-to-markdown)
14
14
  [![Go Reference](https://pkg.go.dev/badge/github.com/Goldziher/html-to-markdown/packages/go/htmltomarkdown.svg)](https://pkg.go.dev/github.com/Goldziher/html-to-markdown/packages/go/htmltomarkdown)
15
15
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Goldziher/html-to-markdown/blob/main/LICENSE)
@@ -219,6 +219,20 @@ Need a call-stack view of the Rust core? Run `task flamegraph:rust` (or call the
219
219
 
220
220
  ## Compatibility (v1 → v2)
221
221
 
222
+ ## Testing
223
+
224
+ Use the task runner to execute the entire matrix locally:
225
+
226
+ ```bash
227
+ # All core test suites (Rust, Python, Ruby, Node, PHP, Go, C#, Elixir, Java)
228
+ task test
229
+
230
+ # Run the Wasmtime-backed WASM integration tests
231
+ task wasm:test:wasmtime
232
+ ```
233
+
234
+ The Wasmtime suite builds the `html-to-markdown-wasm` artifact with the same flags used in CI and drives it through Wasmtime to ensure the non-JS runtime behaves exactly like the browser/Deno builds.
235
+
222
236
  - V2’s Rust core sustains **150–210 MB/s** throughput; V1 averaged **≈ 2.5 MB/s** in its Python/BeautifulSoup implementation (60–80× faster).
223
237
  - The Python package offers a compatibility shim in `html_to_markdown.v1_compat` (`convert_to_markdown`, `convert_to_markdown_stream`, `markdownify`). The shim is deprecated, emits `DeprecationWarning` on every call, and will be removed in v3.0—plan migrations now. Details and keyword mappings live in [Python README](https://github.com/Goldziher/html-to-markdown/blob/main/packages/python/README.md#v1-compatibility).
224
238
  - CLI flag changes, option renames, and other breaking updates are summarised in [CHANGELOG](https://github.com/Goldziher/html-to-markdown/blob/main/CHANGELOG.md#breaking-changes).
@@ -19,16 +19,16 @@
19
19
  * ```
20
20
  */
21
21
  export function convert(html: string, options: any): string;
22
+ export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
23
+ export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
24
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
22
25
  export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
23
- export function convertBytes(html: Uint8Array, options: any): string;
24
26
  export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
25
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
27
+ export function convertBytes(html: Uint8Array, options: any): string;
26
28
  /**
27
29
  * Initialize panic hook for better error messages in the browser
28
30
  */
29
31
  export function init(): void;
30
- export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
31
- export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
32
32
  export class WasmConversionOptionsHandle {
33
33
  free(): void;
34
34
  [Symbol.dispose](): void;
@@ -279,21 +279,35 @@ export function convert(html, options) {
279
279
  }
280
280
  }
281
281
 
282
+ function _assertClass(instance, klass) {
283
+ if (!(instance instanceof klass)) {
284
+ throw new Error(`expected instance of ${klass.name}`);
285
+ }
286
+ }
282
287
  /**
288
+ * @param {string} html
283
289
  * @param {any} options
284
- * @returns {WasmConversionOptionsHandle}
290
+ * @param {WasmInlineImageConfig | null} [image_config]
291
+ * @returns {WasmHtmlExtraction}
285
292
  */
286
- export function createConversionOptionsHandle(options) {
293
+ export function convertWithInlineImages(html, options, image_config) {
287
294
  try {
288
295
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
289
- wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
296
+ const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
297
+ const len0 = WASM_VECTOR_LEN;
298
+ let ptr1 = 0;
299
+ if (!isLikeNone(image_config)) {
300
+ _assertClass(image_config, WasmInlineImageConfig);
301
+ ptr1 = image_config.__destroy_into_raw();
302
+ }
303
+ wasm.convertWithInlineImages(retptr, ptr0, len0, addHeapObject(options), ptr1);
290
304
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
291
305
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
292
306
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
293
307
  if (r2) {
294
308
  throw takeObject(r1);
295
309
  }
296
- return WasmConversionOptionsHandle.__wrap(r0);
310
+ return WasmHtmlExtraction.__wrap(r0);
297
311
  } finally {
298
312
  wasm.__wbindgen_add_to_stack_pointer(16);
299
313
  }
@@ -301,15 +315,16 @@ export function createConversionOptionsHandle(options) {
301
315
 
302
316
  /**
303
317
  * @param {Uint8Array} html
304
- * @param {any} options
318
+ * @param {WasmConversionOptionsHandle} handle
305
319
  * @returns {string}
306
320
  */
307
- export function convertBytes(html, options) {
321
+ export function convertBytesWithOptionsHandle(html, handle) {
308
322
  let deferred2_0;
309
323
  let deferred2_1;
310
324
  try {
311
325
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
312
- wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
326
+ _assertClass(handle, WasmConversionOptionsHandle);
327
+ wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
313
328
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
314
329
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
315
330
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -329,44 +344,6 @@ export function convertBytes(html, options) {
329
344
  }
330
345
  }
331
346
 
332
- function _assertClass(instance, klass) {
333
- if (!(instance instanceof klass)) {
334
- throw new Error(`expected instance of ${klass.name}`);
335
- }
336
- }
337
- /**
338
- * @param {string} html
339
- * @param {WasmConversionOptionsHandle} handle
340
- * @returns {string}
341
- */
342
- export function convertWithOptionsHandle(html, handle) {
343
- let deferred3_0;
344
- let deferred3_1;
345
- try {
346
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
347
- const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
348
- const len0 = WASM_VECTOR_LEN;
349
- _assertClass(handle, WasmConversionOptionsHandle);
350
- wasm.convertWithOptionsHandle(retptr, ptr0, len0, handle.__wbg_ptr);
351
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
352
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
353
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
354
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
355
- var ptr2 = r0;
356
- var len2 = r1;
357
- if (r3) {
358
- ptr2 = 0; len2 = 0;
359
- throw takeObject(r2);
360
- }
361
- deferred3_0 = ptr2;
362
- deferred3_1 = len2;
363
- return getStringFromWasm0(ptr2, len2);
364
- } finally {
365
- wasm.__wbindgen_add_to_stack_pointer(16);
366
- wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
367
- }
368
- }
369
-
370
347
  /**
371
348
  * @param {Uint8Array} html
372
349
  * @param {any} options
@@ -395,53 +372,69 @@ export function convertBytesWithInlineImages(html, options, image_config) {
395
372
  }
396
373
 
397
374
  /**
398
- * Initialize panic hook for better error messages in the browser
375
+ * @param {any} options
376
+ * @returns {WasmConversionOptionsHandle}
399
377
  */
400
- export function init() {
401
- wasm.init();
378
+ export function createConversionOptionsHandle(options) {
379
+ try {
380
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
381
+ wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
382
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
383
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
384
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
385
+ if (r2) {
386
+ throw takeObject(r1);
387
+ }
388
+ return WasmConversionOptionsHandle.__wrap(r0);
389
+ } finally {
390
+ wasm.__wbindgen_add_to_stack_pointer(16);
391
+ }
402
392
  }
403
393
 
404
394
  /**
405
395
  * @param {string} html
406
- * @param {any} options
407
- * @param {WasmInlineImageConfig | null} [image_config]
408
- * @returns {WasmHtmlExtraction}
396
+ * @param {WasmConversionOptionsHandle} handle
397
+ * @returns {string}
409
398
  */
410
- export function convertWithInlineImages(html, options, image_config) {
399
+ export function convertWithOptionsHandle(html, handle) {
400
+ let deferred3_0;
401
+ let deferred3_1;
411
402
  try {
412
403
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
413
404
  const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
414
405
  const len0 = WASM_VECTOR_LEN;
415
- let ptr1 = 0;
416
- if (!isLikeNone(image_config)) {
417
- _assertClass(image_config, WasmInlineImageConfig);
418
- ptr1 = image_config.__destroy_into_raw();
419
- }
420
- wasm.convertWithInlineImages(retptr, ptr0, len0, addHeapObject(options), ptr1);
406
+ _assertClass(handle, WasmConversionOptionsHandle);
407
+ wasm.convertWithOptionsHandle(retptr, ptr0, len0, handle.__wbg_ptr);
421
408
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
422
409
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
423
410
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
424
- if (r2) {
425
- throw takeObject(r1);
411
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
412
+ var ptr2 = r0;
413
+ var len2 = r1;
414
+ if (r3) {
415
+ ptr2 = 0; len2 = 0;
416
+ throw takeObject(r2);
426
417
  }
427
- return WasmHtmlExtraction.__wrap(r0);
418
+ deferred3_0 = ptr2;
419
+ deferred3_1 = len2;
420
+ return getStringFromWasm0(ptr2, len2);
428
421
  } finally {
429
422
  wasm.__wbindgen_add_to_stack_pointer(16);
423
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
430
424
  }
431
425
  }
432
426
 
433
427
  /**
434
428
  * @param {Uint8Array} html
435
- * @param {WasmConversionOptionsHandle} handle
429
+ * @param {any} options
436
430
  * @returns {string}
437
431
  */
438
- export function convertBytesWithOptionsHandle(html, handle) {
432
+ export function convertBytes(html, options) {
439
433
  let deferred2_0;
440
434
  let deferred2_1;
441
435
  try {
442
436
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
443
- _assertClass(handle, WasmConversionOptionsHandle);
444
- wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
437
+ wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
445
438
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
446
439
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
447
440
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -461,6 +454,13 @@ export function convertBytesWithOptionsHandle(html, handle) {
461
454
  }
462
455
  }
463
456
 
457
+ /**
458
+ * Initialize panic hook for better error messages in the browser
459
+ */
460
+ export function init() {
461
+ wasm.init();
462
+ }
463
+
464
464
  const WasmConversionOptionsHandleFinalization = (typeof FinalizationRegistry === 'undefined')
465
465
  ? { register: () => {}, unregister: () => {} }
466
466
  : 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.8.3",
7
+ "version": "2.9.1",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",
@@ -9,7 +9,7 @@ High-performance HTML → Markdown conversion powered by Rust. Shipping as a Rus
9
9
  [![Packagist](https://img.shields.io/packagist/v/goldziher/html-to-markdown.svg)](https://packagist.org/packages/goldziher/html-to-markdown)
10
10
  [![RubyGems](https://badge.fury.io/rb/html-to-markdown.svg)](https://rubygems.org/gems/html-to-markdown)
11
11
  [![Hex.pm](https://img.shields.io/hexpm/v/html_to_markdown.svg)](https://hex.pm/packages/html_to_markdown)
12
- [![NuGet](https://img.shields.io/nuget/v/HtmlToMarkdown.svg)](https://www.nuget.org/packages/HtmlToMarkdown/)
12
+ [![NuGet](https://img.shields.io/nuget/v/Goldziher.HtmlToMarkdown.svg)](https://www.nuget.org/packages/Goldziher.HtmlToMarkdown/)
13
13
  [![Maven Central](https://img.shields.io/maven-central/v/io.github.goldziher/html-to-markdown.svg)](https://central.sonatype.com/artifact/io.github.goldziher/html-to-markdown)
14
14
  [![Go Reference](https://pkg.go.dev/badge/github.com/Goldziher/html-to-markdown/packages/go/htmltomarkdown.svg)](https://pkg.go.dev/github.com/Goldziher/html-to-markdown/packages/go/htmltomarkdown)
15
15
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Goldziher/html-to-markdown/blob/main/LICENSE)
@@ -219,6 +219,20 @@ Need a call-stack view of the Rust core? Run `task flamegraph:rust` (or call the
219
219
 
220
220
  ## Compatibility (v1 → v2)
221
221
 
222
+ ## Testing
223
+
224
+ Use the task runner to execute the entire matrix locally:
225
+
226
+ ```bash
227
+ # All core test suites (Rust, Python, Ruby, Node, PHP, Go, C#, Elixir, Java)
228
+ task test
229
+
230
+ # Run the Wasmtime-backed WASM integration tests
231
+ task wasm:test:wasmtime
232
+ ```
233
+
234
+ The Wasmtime suite builds the `html-to-markdown-wasm` artifact with the same flags used in CI and drives it through Wasmtime to ensure the non-JS runtime behaves exactly like the browser/Deno builds.
235
+
222
236
  - V2’s Rust core sustains **150–210 MB/s** throughput; V1 averaged **≈ 2.5 MB/s** in its Python/BeautifulSoup implementation (60–80× faster).
223
237
  - The Python package offers a compatibility shim in `html_to_markdown.v1_compat` (`convert_to_markdown`, `convert_to_markdown_stream`, `markdownify`). The shim is deprecated, emits `DeprecationWarning` on every call, and will be removed in v3.0—plan migrations now. Details and keyword mappings live in [Python README](https://github.com/Goldziher/html-to-markdown/blob/main/packages/python/README.md#v1-compatibility).
224
238
  - CLI flag changes, option renames, and other breaking updates are summarised in [CHANGELOG](https://github.com/Goldziher/html-to-markdown/blob/main/CHANGELOG.md#breaking-changes).
@@ -19,16 +19,16 @@
19
19
  * ```
20
20
  */
21
21
  export function convert(html: string, options: any): string;
22
+ export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
23
+ export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
24
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
22
25
  export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
23
- export function convertBytes(html: Uint8Array, options: any): string;
24
26
  export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
25
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
27
+ export function convertBytes(html: Uint8Array, options: any): string;
26
28
  /**
27
29
  * Initialize panic hook for better error messages in the browser
28
30
  */
29
31
  export function init(): void;
30
- export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
31
- export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
32
32
  export class WasmConversionOptionsHandle {
33
33
  free(): void;
34
34
  [Symbol.dispose](): void;
@@ -269,21 +269,35 @@ exports.convert = function(html, options) {
269
269
  }
270
270
  };
271
271
 
272
+ function _assertClass(instance, klass) {
273
+ if (!(instance instanceof klass)) {
274
+ throw new Error(`expected instance of ${klass.name}`);
275
+ }
276
+ }
272
277
  /**
278
+ * @param {string} html
273
279
  * @param {any} options
274
- * @returns {WasmConversionOptionsHandle}
280
+ * @param {WasmInlineImageConfig | null} [image_config]
281
+ * @returns {WasmHtmlExtraction}
275
282
  */
276
- exports.createConversionOptionsHandle = function(options) {
283
+ exports.convertWithInlineImages = function(html, options, image_config) {
277
284
  try {
278
285
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
279
- wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
286
+ const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
287
+ const len0 = WASM_VECTOR_LEN;
288
+ let ptr1 = 0;
289
+ if (!isLikeNone(image_config)) {
290
+ _assertClass(image_config, WasmInlineImageConfig);
291
+ ptr1 = image_config.__destroy_into_raw();
292
+ }
293
+ wasm.convertWithInlineImages(retptr, ptr0, len0, addHeapObject(options), ptr1);
280
294
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
281
295
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
282
296
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
283
297
  if (r2) {
284
298
  throw takeObject(r1);
285
299
  }
286
- return WasmConversionOptionsHandle.__wrap(r0);
300
+ return WasmHtmlExtraction.__wrap(r0);
287
301
  } finally {
288
302
  wasm.__wbindgen_add_to_stack_pointer(16);
289
303
  }
@@ -291,15 +305,16 @@ exports.createConversionOptionsHandle = function(options) {
291
305
 
292
306
  /**
293
307
  * @param {Uint8Array} html
294
- * @param {any} options
308
+ * @param {WasmConversionOptionsHandle} handle
295
309
  * @returns {string}
296
310
  */
297
- exports.convertBytes = function(html, options) {
311
+ exports.convertBytesWithOptionsHandle = function(html, handle) {
298
312
  let deferred2_0;
299
313
  let deferred2_1;
300
314
  try {
301
315
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
302
- wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
316
+ _assertClass(handle, WasmConversionOptionsHandle);
317
+ wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
303
318
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
304
319
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
305
320
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -319,44 +334,6 @@ exports.convertBytes = function(html, options) {
319
334
  }
320
335
  };
321
336
 
322
- function _assertClass(instance, klass) {
323
- if (!(instance instanceof klass)) {
324
- throw new Error(`expected instance of ${klass.name}`);
325
- }
326
- }
327
- /**
328
- * @param {string} html
329
- * @param {WasmConversionOptionsHandle} handle
330
- * @returns {string}
331
- */
332
- exports.convertWithOptionsHandle = function(html, handle) {
333
- let deferred3_0;
334
- let deferred3_1;
335
- try {
336
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
337
- const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
338
- const len0 = WASM_VECTOR_LEN;
339
- _assertClass(handle, WasmConversionOptionsHandle);
340
- wasm.convertWithOptionsHandle(retptr, ptr0, len0, handle.__wbg_ptr);
341
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
342
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
343
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
344
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
345
- var ptr2 = r0;
346
- var len2 = r1;
347
- if (r3) {
348
- ptr2 = 0; len2 = 0;
349
- throw takeObject(r2);
350
- }
351
- deferred3_0 = ptr2;
352
- deferred3_1 = len2;
353
- return getStringFromWasm0(ptr2, len2);
354
- } finally {
355
- wasm.__wbindgen_add_to_stack_pointer(16);
356
- wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
357
- }
358
- };
359
-
360
337
  /**
361
338
  * @param {Uint8Array} html
362
339
  * @param {any} options
@@ -385,53 +362,69 @@ exports.convertBytesWithInlineImages = function(html, options, image_config) {
385
362
  };
386
363
 
387
364
  /**
388
- * Initialize panic hook for better error messages in the browser
365
+ * @param {any} options
366
+ * @returns {WasmConversionOptionsHandle}
389
367
  */
390
- exports.init = function() {
391
- wasm.init();
368
+ exports.createConversionOptionsHandle = function(options) {
369
+ try {
370
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
371
+ wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
372
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
373
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
374
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
375
+ if (r2) {
376
+ throw takeObject(r1);
377
+ }
378
+ return WasmConversionOptionsHandle.__wrap(r0);
379
+ } finally {
380
+ wasm.__wbindgen_add_to_stack_pointer(16);
381
+ }
392
382
  };
393
383
 
394
384
  /**
395
385
  * @param {string} html
396
- * @param {any} options
397
- * @param {WasmInlineImageConfig | null} [image_config]
398
- * @returns {WasmHtmlExtraction}
386
+ * @param {WasmConversionOptionsHandle} handle
387
+ * @returns {string}
399
388
  */
400
- exports.convertWithInlineImages = function(html, options, image_config) {
389
+ exports.convertWithOptionsHandle = function(html, handle) {
390
+ let deferred3_0;
391
+ let deferred3_1;
401
392
  try {
402
393
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
403
394
  const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
404
395
  const len0 = WASM_VECTOR_LEN;
405
- let ptr1 = 0;
406
- if (!isLikeNone(image_config)) {
407
- _assertClass(image_config, WasmInlineImageConfig);
408
- ptr1 = image_config.__destroy_into_raw();
409
- }
410
- wasm.convertWithInlineImages(retptr, ptr0, len0, addHeapObject(options), ptr1);
396
+ _assertClass(handle, WasmConversionOptionsHandle);
397
+ wasm.convertWithOptionsHandle(retptr, ptr0, len0, handle.__wbg_ptr);
411
398
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
412
399
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
413
400
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
414
- if (r2) {
415
- throw takeObject(r1);
401
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
402
+ var ptr2 = r0;
403
+ var len2 = r1;
404
+ if (r3) {
405
+ ptr2 = 0; len2 = 0;
406
+ throw takeObject(r2);
416
407
  }
417
- return WasmHtmlExtraction.__wrap(r0);
408
+ deferred3_0 = ptr2;
409
+ deferred3_1 = len2;
410
+ return getStringFromWasm0(ptr2, len2);
418
411
  } finally {
419
412
  wasm.__wbindgen_add_to_stack_pointer(16);
413
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
420
414
  }
421
415
  };
422
416
 
423
417
  /**
424
418
  * @param {Uint8Array} html
425
- * @param {WasmConversionOptionsHandle} handle
419
+ * @param {any} options
426
420
  * @returns {string}
427
421
  */
428
- exports.convertBytesWithOptionsHandle = function(html, handle) {
422
+ exports.convertBytes = function(html, options) {
429
423
  let deferred2_0;
430
424
  let deferred2_1;
431
425
  try {
432
426
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
433
- _assertClass(handle, WasmConversionOptionsHandle);
434
- wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
427
+ wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
435
428
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
436
429
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
437
430
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -451,6 +444,13 @@ exports.convertBytesWithOptionsHandle = function(html, handle) {
451
444
  }
452
445
  };
453
446
 
447
+ /**
448
+ * Initialize panic hook for better error messages in the browser
449
+ */
450
+ exports.init = function() {
451
+ wasm.init();
452
+ };
453
+
454
454
  const WasmConversionOptionsHandleFinalization = (typeof FinalizationRegistry === 'undefined')
455
455
  ? { register: () => {}, unregister: () => {} }
456
456
  : 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.8.3",
6
+ "version": "2.9.1",
7
7
  "license": "MIT",
8
8
  "repository": {
9
9
  "type": "git",
@@ -9,7 +9,7 @@ High-performance HTML → Markdown conversion powered by Rust. Shipping as a Rus
9
9
  [![Packagist](https://img.shields.io/packagist/v/goldziher/html-to-markdown.svg)](https://packagist.org/packages/goldziher/html-to-markdown)
10
10
  [![RubyGems](https://badge.fury.io/rb/html-to-markdown.svg)](https://rubygems.org/gems/html-to-markdown)
11
11
  [![Hex.pm](https://img.shields.io/hexpm/v/html_to_markdown.svg)](https://hex.pm/packages/html_to_markdown)
12
- [![NuGet](https://img.shields.io/nuget/v/HtmlToMarkdown.svg)](https://www.nuget.org/packages/HtmlToMarkdown/)
12
+ [![NuGet](https://img.shields.io/nuget/v/Goldziher.HtmlToMarkdown.svg)](https://www.nuget.org/packages/Goldziher.HtmlToMarkdown/)
13
13
  [![Maven Central](https://img.shields.io/maven-central/v/io.github.goldziher/html-to-markdown.svg)](https://central.sonatype.com/artifact/io.github.goldziher/html-to-markdown)
14
14
  [![Go Reference](https://pkg.go.dev/badge/github.com/Goldziher/html-to-markdown/packages/go/htmltomarkdown.svg)](https://pkg.go.dev/github.com/Goldziher/html-to-markdown/packages/go/htmltomarkdown)
15
15
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Goldziher/html-to-markdown/blob/main/LICENSE)
@@ -219,6 +219,20 @@ Need a call-stack view of the Rust core? Run `task flamegraph:rust` (or call the
219
219
 
220
220
  ## Compatibility (v1 → v2)
221
221
 
222
+ ## Testing
223
+
224
+ Use the task runner to execute the entire matrix locally:
225
+
226
+ ```bash
227
+ # All core test suites (Rust, Python, Ruby, Node, PHP, Go, C#, Elixir, Java)
228
+ task test
229
+
230
+ # Run the Wasmtime-backed WASM integration tests
231
+ task wasm:test:wasmtime
232
+ ```
233
+
234
+ The Wasmtime suite builds the `html-to-markdown-wasm` artifact with the same flags used in CI and drives it through Wasmtime to ensure the non-JS runtime behaves exactly like the browser/Deno builds.
235
+
222
236
  - V2’s Rust core sustains **150–210 MB/s** throughput; V1 averaged **≈ 2.5 MB/s** in its Python/BeautifulSoup implementation (60–80× faster).
223
237
  - The Python package offers a compatibility shim in `html_to_markdown.v1_compat` (`convert_to_markdown`, `convert_to_markdown_stream`, `markdownify`). The shim is deprecated, emits `DeprecationWarning` on every call, and will be removed in v3.0—plan migrations now. Details and keyword mappings live in [Python README](https://github.com/Goldziher/html-to-markdown/blob/main/packages/python/README.md#v1-compatibility).
224
238
  - CLI flag changes, option renames, and other breaking updates are summarised in [CHANGELOG](https://github.com/Goldziher/html-to-markdown/blob/main/CHANGELOG.md#breaking-changes).
@@ -19,16 +19,16 @@
19
19
  * ```
20
20
  */
21
21
  export function convert(html: string, options: any): string;
22
+ export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
23
+ export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
24
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
22
25
  export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
23
- export function convertBytes(html: Uint8Array, options: any): string;
24
26
  export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
25
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
27
+ export function convertBytes(html: Uint8Array, options: any): string;
26
28
  /**
27
29
  * Initialize panic hook for better error messages in the browser
28
30
  */
29
31
  export function init(): void;
30
- export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
31
- export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
32
32
  export class WasmConversionOptionsHandle {
33
33
  free(): void;
34
34
  [Symbol.dispose](): void;
@@ -275,21 +275,35 @@ export function convert(html, options) {
275
275
  }
276
276
  }
277
277
 
278
+ function _assertClass(instance, klass) {
279
+ if (!(instance instanceof klass)) {
280
+ throw new Error(`expected instance of ${klass.name}`);
281
+ }
282
+ }
278
283
  /**
284
+ * @param {string} html
279
285
  * @param {any} options
280
- * @returns {WasmConversionOptionsHandle}
286
+ * @param {WasmInlineImageConfig | null} [image_config]
287
+ * @returns {WasmHtmlExtraction}
281
288
  */
282
- export function createConversionOptionsHandle(options) {
289
+ export function convertWithInlineImages(html, options, image_config) {
283
290
  try {
284
291
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
285
- wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
292
+ const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
293
+ const len0 = WASM_VECTOR_LEN;
294
+ let ptr1 = 0;
295
+ if (!isLikeNone(image_config)) {
296
+ _assertClass(image_config, WasmInlineImageConfig);
297
+ ptr1 = image_config.__destroy_into_raw();
298
+ }
299
+ wasm.convertWithInlineImages(retptr, ptr0, len0, addHeapObject(options), ptr1);
286
300
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
287
301
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
288
302
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
289
303
  if (r2) {
290
304
  throw takeObject(r1);
291
305
  }
292
- return WasmConversionOptionsHandle.__wrap(r0);
306
+ return WasmHtmlExtraction.__wrap(r0);
293
307
  } finally {
294
308
  wasm.__wbindgen_add_to_stack_pointer(16);
295
309
  }
@@ -297,15 +311,16 @@ export function createConversionOptionsHandle(options) {
297
311
 
298
312
  /**
299
313
  * @param {Uint8Array} html
300
- * @param {any} options
314
+ * @param {WasmConversionOptionsHandle} handle
301
315
  * @returns {string}
302
316
  */
303
- export function convertBytes(html, options) {
317
+ export function convertBytesWithOptionsHandle(html, handle) {
304
318
  let deferred2_0;
305
319
  let deferred2_1;
306
320
  try {
307
321
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
308
- wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
322
+ _assertClass(handle, WasmConversionOptionsHandle);
323
+ wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
309
324
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
310
325
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
311
326
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -325,44 +340,6 @@ export function convertBytes(html, options) {
325
340
  }
326
341
  }
327
342
 
328
- function _assertClass(instance, klass) {
329
- if (!(instance instanceof klass)) {
330
- throw new Error(`expected instance of ${klass.name}`);
331
- }
332
- }
333
- /**
334
- * @param {string} html
335
- * @param {WasmConversionOptionsHandle} handle
336
- * @returns {string}
337
- */
338
- export function convertWithOptionsHandle(html, handle) {
339
- let deferred3_0;
340
- let deferred3_1;
341
- try {
342
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
343
- const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
344
- const len0 = WASM_VECTOR_LEN;
345
- _assertClass(handle, WasmConversionOptionsHandle);
346
- wasm.convertWithOptionsHandle(retptr, ptr0, len0, handle.__wbg_ptr);
347
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
348
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
349
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
350
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
351
- var ptr2 = r0;
352
- var len2 = r1;
353
- if (r3) {
354
- ptr2 = 0; len2 = 0;
355
- throw takeObject(r2);
356
- }
357
- deferred3_0 = ptr2;
358
- deferred3_1 = len2;
359
- return getStringFromWasm0(ptr2, len2);
360
- } finally {
361
- wasm.__wbindgen_add_to_stack_pointer(16);
362
- wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
363
- }
364
- }
365
-
366
343
  /**
367
344
  * @param {Uint8Array} html
368
345
  * @param {any} options
@@ -391,53 +368,69 @@ export function convertBytesWithInlineImages(html, options, image_config) {
391
368
  }
392
369
 
393
370
  /**
394
- * Initialize panic hook for better error messages in the browser
371
+ * @param {any} options
372
+ * @returns {WasmConversionOptionsHandle}
395
373
  */
396
- export function init() {
397
- wasm.init();
374
+ export function createConversionOptionsHandle(options) {
375
+ try {
376
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
377
+ wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
378
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
379
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
380
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
381
+ if (r2) {
382
+ throw takeObject(r1);
383
+ }
384
+ return WasmConversionOptionsHandle.__wrap(r0);
385
+ } finally {
386
+ wasm.__wbindgen_add_to_stack_pointer(16);
387
+ }
398
388
  }
399
389
 
400
390
  /**
401
391
  * @param {string} html
402
- * @param {any} options
403
- * @param {WasmInlineImageConfig | null} [image_config]
404
- * @returns {WasmHtmlExtraction}
392
+ * @param {WasmConversionOptionsHandle} handle
393
+ * @returns {string}
405
394
  */
406
- export function convertWithInlineImages(html, options, image_config) {
395
+ export function convertWithOptionsHandle(html, handle) {
396
+ let deferred3_0;
397
+ let deferred3_1;
407
398
  try {
408
399
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
409
400
  const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
410
401
  const len0 = WASM_VECTOR_LEN;
411
- let ptr1 = 0;
412
- if (!isLikeNone(image_config)) {
413
- _assertClass(image_config, WasmInlineImageConfig);
414
- ptr1 = image_config.__destroy_into_raw();
415
- }
416
- wasm.convertWithInlineImages(retptr, ptr0, len0, addHeapObject(options), ptr1);
402
+ _assertClass(handle, WasmConversionOptionsHandle);
403
+ wasm.convertWithOptionsHandle(retptr, ptr0, len0, handle.__wbg_ptr);
417
404
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
418
405
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
419
406
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
420
- if (r2) {
421
- throw takeObject(r1);
407
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
408
+ var ptr2 = r0;
409
+ var len2 = r1;
410
+ if (r3) {
411
+ ptr2 = 0; len2 = 0;
412
+ throw takeObject(r2);
422
413
  }
423
- return WasmHtmlExtraction.__wrap(r0);
414
+ deferred3_0 = ptr2;
415
+ deferred3_1 = len2;
416
+ return getStringFromWasm0(ptr2, len2);
424
417
  } finally {
425
418
  wasm.__wbindgen_add_to_stack_pointer(16);
419
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
426
420
  }
427
421
  }
428
422
 
429
423
  /**
430
424
  * @param {Uint8Array} html
431
- * @param {WasmConversionOptionsHandle} handle
425
+ * @param {any} options
432
426
  * @returns {string}
433
427
  */
434
- export function convertBytesWithOptionsHandle(html, handle) {
428
+ export function convertBytes(html, options) {
435
429
  let deferred2_0;
436
430
  let deferred2_1;
437
431
  try {
438
432
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
439
- _assertClass(handle, WasmConversionOptionsHandle);
440
- wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
433
+ wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
441
434
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
442
435
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
443
436
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -457,6 +450,13 @@ export function convertBytesWithOptionsHandle(html, handle) {
457
450
  }
458
451
  }
459
452
 
453
+ /**
454
+ * Initialize panic hook for better error messages in the browser
455
+ */
456
+ export function init() {
457
+ wasm.init();
458
+ }
459
+
460
460
  const WasmConversionOptionsHandleFinalization = (typeof FinalizationRegistry === 'undefined')
461
461
  ? { register: () => {}, unregister: () => {} }
462
462
  : 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.8.3",
7
+ "version": "2.9.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.8.3",
3
+ "version": "2.9.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",
@@ -55,7 +55,7 @@
55
55
  "devDependencies": {
56
56
  "@types/node": "^24.10.1",
57
57
  "tsx": "^4.20.6",
58
- "vitest": "^4.0.8",
58
+ "vitest": "^4.0.11",
59
59
  "wasm-pack": "^0.13.1"
60
60
  },
61
61
  "publishConfig": {