html-to-markdown-wasm 2.8.3 → 2.9.0

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).
@@ -1,5 +1,10 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ /**
4
+ * Initialize panic hook for better error messages in the browser
5
+ */
6
+ export function init(): void;
7
+ export function convertBytes(html: Uint8Array, options: any): string;
3
8
  /**
4
9
  * Convert HTML to Markdown
5
10
  *
@@ -19,16 +24,11 @@
19
24
  * ```
20
25
  */
21
26
  export function convert(html: string, options: any): string;
22
- export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
23
- export function convertBytes(html: Uint8Array, options: any): string;
24
- export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
25
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
26
- /**
27
- * Initialize panic hook for better error messages in the browser
28
- */
29
- export function init(): void;
30
27
  export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
31
28
  export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
29
+ export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
30
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
31
+ export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
32
32
  export class WasmConversionOptionsHandle {
33
33
  free(): void;
34
34
  [Symbol.dispose](): void;
@@ -231,6 +231,43 @@ function getArrayJsValueFromWasm0(ptr, len) {
231
231
  }
232
232
  return result;
233
233
  }
234
+ /**
235
+ * Initialize panic hook for better error messages in the browser
236
+ */
237
+ export function init() {
238
+ wasm.init();
239
+ }
240
+
241
+ /**
242
+ * @param {Uint8Array} html
243
+ * @param {any} options
244
+ * @returns {string}
245
+ */
246
+ export function convertBytes(html, options) {
247
+ let deferred2_0;
248
+ let deferred2_1;
249
+ try {
250
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
251
+ wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
252
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
253
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
254
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
255
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
256
+ var ptr1 = r0;
257
+ var len1 = r1;
258
+ if (r3) {
259
+ ptr1 = 0; len1 = 0;
260
+ throw takeObject(r2);
261
+ }
262
+ deferred2_0 = ptr1;
263
+ deferred2_1 = len1;
264
+ return getStringFromWasm0(ptr1, len1);
265
+ } finally {
266
+ wasm.__wbindgen_add_to_stack_pointer(16);
267
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
268
+ }
269
+ }
270
+
234
271
  /**
235
272
  * Convert HTML to Markdown
236
273
  *
@@ -279,21 +316,35 @@ export function convert(html, options) {
279
316
  }
280
317
  }
281
318
 
319
+ function _assertClass(instance, klass) {
320
+ if (!(instance instanceof klass)) {
321
+ throw new Error(`expected instance of ${klass.name}`);
322
+ }
323
+ }
282
324
  /**
325
+ * @param {string} html
283
326
  * @param {any} options
284
- * @returns {WasmConversionOptionsHandle}
327
+ * @param {WasmInlineImageConfig | null} [image_config]
328
+ * @returns {WasmHtmlExtraction}
285
329
  */
286
- export function createConversionOptionsHandle(options) {
330
+ export function convertWithInlineImages(html, options, image_config) {
287
331
  try {
288
332
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
289
- wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
333
+ const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
334
+ const len0 = WASM_VECTOR_LEN;
335
+ let ptr1 = 0;
336
+ if (!isLikeNone(image_config)) {
337
+ _assertClass(image_config, WasmInlineImageConfig);
338
+ ptr1 = image_config.__destroy_into_raw();
339
+ }
340
+ wasm.convertWithInlineImages(retptr, ptr0, len0, addHeapObject(options), ptr1);
290
341
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
291
342
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
292
343
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
293
344
  if (r2) {
294
345
  throw takeObject(r1);
295
346
  }
296
- return WasmConversionOptionsHandle.__wrap(r0);
347
+ return WasmHtmlExtraction.__wrap(r0);
297
348
  } finally {
298
349
  wasm.__wbindgen_add_to_stack_pointer(16);
299
350
  }
@@ -301,15 +352,16 @@ export function createConversionOptionsHandle(options) {
301
352
 
302
353
  /**
303
354
  * @param {Uint8Array} html
304
- * @param {any} options
355
+ * @param {WasmConversionOptionsHandle} handle
305
356
  * @returns {string}
306
357
  */
307
- export function convertBytes(html, options) {
358
+ export function convertBytesWithOptionsHandle(html, handle) {
308
359
  let deferred2_0;
309
360
  let deferred2_1;
310
361
  try {
311
362
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
312
- wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
363
+ _assertClass(handle, WasmConversionOptionsHandle);
364
+ wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
313
365
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
314
366
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
315
367
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -329,11 +381,6 @@ export function convertBytes(html, options) {
329
381
  }
330
382
  }
331
383
 
332
- function _assertClass(instance, klass) {
333
- if (!(instance instanceof klass)) {
334
- throw new Error(`expected instance of ${klass.name}`);
335
- }
336
- }
337
384
  /**
338
385
  * @param {string} html
339
386
  * @param {WasmConversionOptionsHandle} handle
@@ -395,69 +442,22 @@ export function convertBytesWithInlineImages(html, options, image_config) {
395
442
  }
396
443
 
397
444
  /**
398
- * Initialize panic hook for better error messages in the browser
399
- */
400
- export function init() {
401
- wasm.init();
402
- }
403
-
404
- /**
405
- * @param {string} html
406
445
  * @param {any} options
407
- * @param {WasmInlineImageConfig | null} [image_config]
408
- * @returns {WasmHtmlExtraction}
446
+ * @returns {WasmConversionOptionsHandle}
409
447
  */
410
- export function convertWithInlineImages(html, options, image_config) {
448
+ export function createConversionOptionsHandle(options) {
411
449
  try {
412
450
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
413
- const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
414
- 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);
451
+ wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
421
452
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
422
453
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
423
454
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
424
455
  if (r2) {
425
456
  throw takeObject(r1);
426
457
  }
427
- return WasmHtmlExtraction.__wrap(r0);
428
- } finally {
429
- wasm.__wbindgen_add_to_stack_pointer(16);
430
- }
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
+ return WasmConversionOptionsHandle.__wrap(r0);
458
459
  } finally {
459
460
  wasm.__wbindgen_add_to_stack_pointer(16);
460
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
461
461
  }
462
462
  }
463
463
 
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.0",
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).
@@ -1,5 +1,10 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ /**
4
+ * Initialize panic hook for better error messages in the browser
5
+ */
6
+ export function init(): void;
7
+ export function convertBytes(html: Uint8Array, options: any): string;
3
8
  /**
4
9
  * Convert HTML to Markdown
5
10
  *
@@ -19,16 +24,11 @@
19
24
  * ```
20
25
  */
21
26
  export function convert(html: string, options: any): string;
22
- export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
23
- export function convertBytes(html: Uint8Array, options: any): string;
24
- export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
25
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
26
- /**
27
- * Initialize panic hook for better error messages in the browser
28
- */
29
- export function init(): void;
30
27
  export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
31
28
  export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
29
+ export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
30
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
31
+ export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
32
32
  export class WasmConversionOptionsHandle {
33
33
  free(): void;
34
34
  [Symbol.dispose](): void;
@@ -221,6 +221,43 @@ function getArrayJsValueFromWasm0(ptr, len) {
221
221
  }
222
222
  return result;
223
223
  }
224
+ /**
225
+ * Initialize panic hook for better error messages in the browser
226
+ */
227
+ exports.init = function() {
228
+ wasm.init();
229
+ };
230
+
231
+ /**
232
+ * @param {Uint8Array} html
233
+ * @param {any} options
234
+ * @returns {string}
235
+ */
236
+ exports.convertBytes = function(html, options) {
237
+ let deferred2_0;
238
+ let deferred2_1;
239
+ try {
240
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
241
+ wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
242
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
243
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
244
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
245
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
246
+ var ptr1 = r0;
247
+ var len1 = r1;
248
+ if (r3) {
249
+ ptr1 = 0; len1 = 0;
250
+ throw takeObject(r2);
251
+ }
252
+ deferred2_0 = ptr1;
253
+ deferred2_1 = len1;
254
+ return getStringFromWasm0(ptr1, len1);
255
+ } finally {
256
+ wasm.__wbindgen_add_to_stack_pointer(16);
257
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
258
+ }
259
+ };
260
+
224
261
  /**
225
262
  * Convert HTML to Markdown
226
263
  *
@@ -269,21 +306,35 @@ exports.convert = function(html, options) {
269
306
  }
270
307
  };
271
308
 
309
+ function _assertClass(instance, klass) {
310
+ if (!(instance instanceof klass)) {
311
+ throw new Error(`expected instance of ${klass.name}`);
312
+ }
313
+ }
272
314
  /**
315
+ * @param {string} html
273
316
  * @param {any} options
274
- * @returns {WasmConversionOptionsHandle}
317
+ * @param {WasmInlineImageConfig | null} [image_config]
318
+ * @returns {WasmHtmlExtraction}
275
319
  */
276
- exports.createConversionOptionsHandle = function(options) {
320
+ exports.convertWithInlineImages = function(html, options, image_config) {
277
321
  try {
278
322
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
279
- wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
323
+ const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
324
+ const len0 = WASM_VECTOR_LEN;
325
+ let ptr1 = 0;
326
+ if (!isLikeNone(image_config)) {
327
+ _assertClass(image_config, WasmInlineImageConfig);
328
+ ptr1 = image_config.__destroy_into_raw();
329
+ }
330
+ wasm.convertWithInlineImages(retptr, ptr0, len0, addHeapObject(options), ptr1);
280
331
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
281
332
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
282
333
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
283
334
  if (r2) {
284
335
  throw takeObject(r1);
285
336
  }
286
- return WasmConversionOptionsHandle.__wrap(r0);
337
+ return WasmHtmlExtraction.__wrap(r0);
287
338
  } finally {
288
339
  wasm.__wbindgen_add_to_stack_pointer(16);
289
340
  }
@@ -291,15 +342,16 @@ exports.createConversionOptionsHandle = function(options) {
291
342
 
292
343
  /**
293
344
  * @param {Uint8Array} html
294
- * @param {any} options
345
+ * @param {WasmConversionOptionsHandle} handle
295
346
  * @returns {string}
296
347
  */
297
- exports.convertBytes = function(html, options) {
348
+ exports.convertBytesWithOptionsHandle = function(html, handle) {
298
349
  let deferred2_0;
299
350
  let deferred2_1;
300
351
  try {
301
352
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
302
- wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
353
+ _assertClass(handle, WasmConversionOptionsHandle);
354
+ wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
303
355
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
304
356
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
305
357
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -319,11 +371,6 @@ exports.convertBytes = function(html, options) {
319
371
  }
320
372
  };
321
373
 
322
- function _assertClass(instance, klass) {
323
- if (!(instance instanceof klass)) {
324
- throw new Error(`expected instance of ${klass.name}`);
325
- }
326
- }
327
374
  /**
328
375
  * @param {string} html
329
376
  * @param {WasmConversionOptionsHandle} handle
@@ -385,69 +432,22 @@ exports.convertBytesWithInlineImages = function(html, options, image_config) {
385
432
  };
386
433
 
387
434
  /**
388
- * Initialize panic hook for better error messages in the browser
389
- */
390
- exports.init = function() {
391
- wasm.init();
392
- };
393
-
394
- /**
395
- * @param {string} html
396
435
  * @param {any} options
397
- * @param {WasmInlineImageConfig | null} [image_config]
398
- * @returns {WasmHtmlExtraction}
436
+ * @returns {WasmConversionOptionsHandle}
399
437
  */
400
- exports.convertWithInlineImages = function(html, options, image_config) {
438
+ exports.createConversionOptionsHandle = function(options) {
401
439
  try {
402
440
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
403
- const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
404
- 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);
441
+ wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
411
442
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
412
443
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
413
444
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
414
445
  if (r2) {
415
446
  throw takeObject(r1);
416
447
  }
417
- return WasmHtmlExtraction.__wrap(r0);
418
- } finally {
419
- wasm.__wbindgen_add_to_stack_pointer(16);
420
- }
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
+ return WasmConversionOptionsHandle.__wrap(r0);
448
449
  } finally {
449
450
  wasm.__wbindgen_add_to_stack_pointer(16);
450
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
451
451
  }
452
452
  };
453
453
 
@@ -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.0",
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).
@@ -1,5 +1,10 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ /**
4
+ * Initialize panic hook for better error messages in the browser
5
+ */
6
+ export function init(): void;
7
+ export function convertBytes(html: Uint8Array, options: any): string;
3
8
  /**
4
9
  * Convert HTML to Markdown
5
10
  *
@@ -19,16 +24,11 @@
19
24
  * ```
20
25
  */
21
26
  export function convert(html: string, options: any): string;
22
- export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
23
- export function convertBytes(html: Uint8Array, options: any): string;
24
- export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
25
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
26
- /**
27
- * Initialize panic hook for better error messages in the browser
28
- */
29
- export function init(): void;
30
27
  export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
31
28
  export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
29
+ export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
30
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
31
+ export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
32
32
  export class WasmConversionOptionsHandle {
33
33
  free(): void;
34
34
  [Symbol.dispose](): void;
@@ -227,6 +227,43 @@ function getArrayJsValueFromWasm0(ptr, len) {
227
227
  }
228
228
  return result;
229
229
  }
230
+ /**
231
+ * Initialize panic hook for better error messages in the browser
232
+ */
233
+ export function init() {
234
+ wasm.init();
235
+ }
236
+
237
+ /**
238
+ * @param {Uint8Array} html
239
+ * @param {any} options
240
+ * @returns {string}
241
+ */
242
+ export function convertBytes(html, options) {
243
+ let deferred2_0;
244
+ let deferred2_1;
245
+ try {
246
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
247
+ wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
248
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
249
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
250
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
251
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
252
+ var ptr1 = r0;
253
+ var len1 = r1;
254
+ if (r3) {
255
+ ptr1 = 0; len1 = 0;
256
+ throw takeObject(r2);
257
+ }
258
+ deferred2_0 = ptr1;
259
+ deferred2_1 = len1;
260
+ return getStringFromWasm0(ptr1, len1);
261
+ } finally {
262
+ wasm.__wbindgen_add_to_stack_pointer(16);
263
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
264
+ }
265
+ }
266
+
230
267
  /**
231
268
  * Convert HTML to Markdown
232
269
  *
@@ -275,21 +312,35 @@ export function convert(html, options) {
275
312
  }
276
313
  }
277
314
 
315
+ function _assertClass(instance, klass) {
316
+ if (!(instance instanceof klass)) {
317
+ throw new Error(`expected instance of ${klass.name}`);
318
+ }
319
+ }
278
320
  /**
321
+ * @param {string} html
279
322
  * @param {any} options
280
- * @returns {WasmConversionOptionsHandle}
323
+ * @param {WasmInlineImageConfig | null} [image_config]
324
+ * @returns {WasmHtmlExtraction}
281
325
  */
282
- export function createConversionOptionsHandle(options) {
326
+ export function convertWithInlineImages(html, options, image_config) {
283
327
  try {
284
328
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
285
- wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
329
+ const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
330
+ const len0 = WASM_VECTOR_LEN;
331
+ let ptr1 = 0;
332
+ if (!isLikeNone(image_config)) {
333
+ _assertClass(image_config, WasmInlineImageConfig);
334
+ ptr1 = image_config.__destroy_into_raw();
335
+ }
336
+ wasm.convertWithInlineImages(retptr, ptr0, len0, addHeapObject(options), ptr1);
286
337
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
287
338
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
288
339
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
289
340
  if (r2) {
290
341
  throw takeObject(r1);
291
342
  }
292
- return WasmConversionOptionsHandle.__wrap(r0);
343
+ return WasmHtmlExtraction.__wrap(r0);
293
344
  } finally {
294
345
  wasm.__wbindgen_add_to_stack_pointer(16);
295
346
  }
@@ -297,15 +348,16 @@ export function createConversionOptionsHandle(options) {
297
348
 
298
349
  /**
299
350
  * @param {Uint8Array} html
300
- * @param {any} options
351
+ * @param {WasmConversionOptionsHandle} handle
301
352
  * @returns {string}
302
353
  */
303
- export function convertBytes(html, options) {
354
+ export function convertBytesWithOptionsHandle(html, handle) {
304
355
  let deferred2_0;
305
356
  let deferred2_1;
306
357
  try {
307
358
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
308
- wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
359
+ _assertClass(handle, WasmConversionOptionsHandle);
360
+ wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
309
361
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
310
362
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
311
363
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -325,11 +377,6 @@ export function convertBytes(html, options) {
325
377
  }
326
378
  }
327
379
 
328
- function _assertClass(instance, klass) {
329
- if (!(instance instanceof klass)) {
330
- throw new Error(`expected instance of ${klass.name}`);
331
- }
332
- }
333
380
  /**
334
381
  * @param {string} html
335
382
  * @param {WasmConversionOptionsHandle} handle
@@ -391,69 +438,22 @@ export function convertBytesWithInlineImages(html, options, image_config) {
391
438
  }
392
439
 
393
440
  /**
394
- * Initialize panic hook for better error messages in the browser
395
- */
396
- export function init() {
397
- wasm.init();
398
- }
399
-
400
- /**
401
- * @param {string} html
402
441
  * @param {any} options
403
- * @param {WasmInlineImageConfig | null} [image_config]
404
- * @returns {WasmHtmlExtraction}
442
+ * @returns {WasmConversionOptionsHandle}
405
443
  */
406
- export function convertWithInlineImages(html, options, image_config) {
444
+ export function createConversionOptionsHandle(options) {
407
445
  try {
408
446
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
409
- const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
410
- 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);
447
+ wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
417
448
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
418
449
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
419
450
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
420
451
  if (r2) {
421
452
  throw takeObject(r1);
422
453
  }
423
- return WasmHtmlExtraction.__wrap(r0);
424
- } finally {
425
- wasm.__wbindgen_add_to_stack_pointer(16);
426
- }
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
+ return WasmConversionOptionsHandle.__wrap(r0);
454
455
  } finally {
455
456
  wasm.__wbindgen_add_to_stack_pointer(16);
456
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
457
457
  }
458
458
  }
459
459
 
@@ -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.0",
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.0",
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": {