html-to-markdown-wasm 2.7.1 → 2.8.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
@@ -9,12 +9,15 @@ Powered by the same Rust engine as the Node.js, Python, Ruby, and PHP bindings,
9
9
 
10
10
  Runs anywhere: Node.js, Deno, Bun, browsers, and edge runtimes.
11
11
 
12
- [![Crates.io](https://img.shields.io/crates/v/html-to-markdown-rs.svg)](https://crates.io/crates/html-to-markdown-rs)
12
+ [![Crates.io](https://img.shields.io/crates/v/html-to-markdown.svg)](https://crates.io/crates/html-to-markdown)
13
13
  [![npm (node)](https://badge.fury.io/js/html-to-markdown-node.svg)](https://www.npmjs.com/package/html-to-markdown-node)
14
14
  [![npm (wasm)](https://badge.fury.io/js/html-to-markdown-wasm.svg)](https://www.npmjs.com/package/html-to-markdown-wasm)
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/)
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
+ [![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)
18
21
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Goldziher/html-to-markdown/blob/main/LICENSE)
19
22
 
20
23
  ## Performance
@@ -92,6 +95,8 @@ console.log(markdown);
92
95
  // This is **fast**!
93
96
  ```
94
97
 
98
+ > **Heads up for edge runtimes:** Cloudflare Workers, Vite dev servers, and other environments that instantiate `.wasm` files asynchronously must call `await initWasm()` (or `await wasmReady`) once during startup before invoking `convert`. Traditional bundlers (Webpack, Rollup) and Deno/Node imports continue to work without manual initialization.
99
+
95
100
  ### Reusing Options Handles
96
101
 
97
102
  ```ts
@@ -212,10 +217,15 @@ const markdown = convert('<h1>Hello</h1>', {
212
217
  ### Cloudflare Workers
213
218
 
214
219
  ```typescript
215
- import { convert } from 'html-to-markdown-wasm';
220
+ import { convert, initWasm, wasmReady } from 'html-to-markdown-wasm';
221
+
222
+ // Cloudflare Workers / other edge runtimes instantiate WASM asynchronously.
223
+ // Kick off initialization once at module scope.
224
+ const ready = wasmReady ?? initWasm();
216
225
 
217
226
  export default {
218
227
  async fetch(request: Request): Promise<Response> {
228
+ await ready;
219
229
  const html = await request.text();
220
230
  const markdown = convert(html, { headingStyle: 'atx' });
221
231
 
package/dist/README.md CHANGED
@@ -2,12 +2,15 @@
2
2
 
3
3
  High-performance HTML → Markdown conversion powered by Rust. Shipping as a Rust crate, Python package, PHP extension, Ruby gem, Node.js bindings, WebAssembly, and standalone CLI with identical rendering behaviour.
4
4
 
5
- [![Crates.io](https://img.shields.io/crates/v/html-to-markdown-rs.svg)](https://crates.io/crates/html-to-markdown-rs)
5
+ [![Crates.io](https://img.shields.io/crates/v/html-to-markdown.svg)](https://crates.io/crates/html-to-markdown)
6
6
  [![npm (node)](https://badge.fury.io/js/html-to-markdown-node.svg)](https://www.npmjs.com/package/html-to-markdown-node)
7
7
  [![npm (wasm)](https://badge.fury.io/js/html-to-markdown-wasm.svg)](https://www.npmjs.com/package/html-to-markdown-wasm)
8
8
  [![PyPI](https://badge.fury.io/py/html-to-markdown.svg)](https://pypi.org/project/html-to-markdown/)
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
+ [![NuGet](https://img.shields.io/nuget/v/HtmlToMarkdown.svg)](https://www.nuget.org/packages/HtmlToMarkdown/)
12
+ [![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)
13
+ [![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)
11
14
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Goldziher/html-to-markdown/blob/main/LICENSE)
12
15
  [![Discord](https://img.shields.io/badge/Discord-Join%20our%20community-7289da)](https://discord.gg/pXxagNK2zN)
13
16
 
@@ -89,7 +92,7 @@ const markdown = convert(html, {
89
92
  });
90
93
  ```
91
94
 
92
- **Performance:** The shared fixture harness (`task bench:bindings`) now clocks Node, Python, and the Rust CLI at ~1.3–1.4k ops/sec (≈150MB/s) on the 129KB Wikipedia Lists page thanks to the new Buffer/Uint8Array fast paths and release-mode harness. Ruby stays close at ~1.2k ops/sec, PHP lands around 0.3k ops/sec (≈35 MB/s), and WASM hits ~0.85k ops/sec—plenty for browsers, Deno, and edge runtimes.
95
+ **Performance:** The shared fixture harness (`task bench:bindings`) now clocks C# at ~1.4k ops/sec (≈171 MB/s), Go at ~1.3k ops/sec (≈165 MB/s), Node, Python, and the Rust CLI at ~1.3–1.4k ops/sec (≈150 MB/s) on the 129 KB Wikipedia "Lists" page thanks to the new Buffer/Uint8Array fast paths and release-mode harness. Ruby stays close at ~1.2k ops/sec (≈150 MB/s), Java lands at ~1.0k ops/sec (≈126 MB/s), WASM hits ~0.85k ops/sec (≈108 MB/s), and PHP achieves ~0.3k ops/sec (≈35 MB/s)—all providing excellent throughput for production workloads.
93
96
 
94
97
  See the JavaScript guides for full API documentation:
95
98
 
@@ -1,8 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
4
3
  export function convertBytes(html: Uint8Array, options: any): string;
5
- export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
6
4
  /**
7
5
  * Convert HTML to Markdown
8
6
  *
@@ -23,11 +21,13 @@ export function createConversionOptionsHandle(options: any): WasmConversionOptio
23
21
  */
24
22
  export function convert(html: string, options: any): string;
25
23
  export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
26
- export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
27
24
  /**
28
25
  * Initialize panic hook for better error messages in the browser
29
26
  */
30
27
  export function init(): void;
28
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
29
+ export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
30
+ export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
31
31
  export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
32
32
  export class WasmConversionOptionsHandle {
33
33
  free(): void;
@@ -81,3 +81,6 @@ export class WasmInlineImageWarning {
81
81
  readonly index: number;
82
82
  readonly message: string;
83
83
  }
84
+
85
+ export declare function initWasm(): Promise<void>;
86
+ export declare const wasmReady: Promise<void>;
@@ -1,5 +1,94 @@
1
- import * as wasm from "./html_to_markdown_wasm_bg.wasm";
1
+ import * as wasmModule from "./html_to_markdown_wasm_bg.wasm";
2
2
  export * from "./html_to_markdown_wasm_bg.js";
3
3
  import { __wbg_set_wasm } from "./html_to_markdown_wasm_bg.js";
4
- __wbg_set_wasm(wasm);
5
- wasm.__wbindgen_start();
4
+
5
+ const notReadyError = () =>
6
+ new Error("html-to-markdown-wasm: WebAssembly bundle is still initializing. Await initWasm() before calling convert() in runtimes that load WASM asynchronously (e.g., Cloudflare Workers).");
7
+
8
+ const notReadyProxy = new Proxy({}, {
9
+ get(_target, prop) {
10
+ if (prop === "__esModule") {
11
+ return true;
12
+ }
13
+ throw notReadyError();
14
+ }
15
+ });
16
+
17
+ let wasmExports;
18
+ let initialized = false;
19
+ let initPromise;
20
+
21
+ __wbg_set_wasm(notReadyProxy);
22
+
23
+ function asExports(value) {
24
+ if (!value) {
25
+ return null;
26
+ }
27
+ if (typeof value.__wbindgen_start === "function") {
28
+ return value;
29
+ }
30
+ if (value instanceof WebAssembly.Instance) {
31
+ return value.exports;
32
+ }
33
+ if (typeof value === "object") {
34
+ if (value.instance instanceof WebAssembly.Instance) {
35
+ return value.instance.exports;
36
+ }
37
+ if (value.default instanceof WebAssembly.Instance) {
38
+ return value.default.exports;
39
+ }
40
+ if (value.default && value.default.instance instanceof WebAssembly.Instance) {
41
+ return value.default.instance.exports;
42
+ }
43
+ }
44
+ return null;
45
+ }
46
+
47
+ function finalize(exports) {
48
+ wasmExports = exports;
49
+ __wbg_set_wasm(exports);
50
+ if (typeof exports.__wbindgen_start === "function") {
51
+ exports.__wbindgen_start();
52
+ }
53
+ initialized = true;
54
+ return exports;
55
+ }
56
+
57
+ function trySyncInit() {
58
+ try {
59
+ const exports = asExports(wasmModule);
60
+ if (exports) {
61
+ finalize(exports);
62
+ }
63
+ } catch {
64
+ // ignore and fall back to async init
65
+ }
66
+ }
67
+
68
+ trySyncInit();
69
+
70
+ function ensureInitPromise() {
71
+ if (initialized) {
72
+ return Promise.resolve(wasmExports);
73
+ }
74
+ if (!initPromise) {
75
+ initPromise = (async () => {
76
+ let module = wasmModule;
77
+ if (module && typeof module.then === "function") {
78
+ module = await module;
79
+ }
80
+ const exports = asExports(module);
81
+ if (!exports) {
82
+ throw new Error("html-to-markdown-wasm: failed to initialize WebAssembly bundle. Call initWasm() with a supported bundler configuration.");
83
+ }
84
+ return finalize(exports);
85
+ })();
86
+ }
87
+ return initPromise;
88
+ }
89
+
90
+ export const wasmReady = ensureInitPromise();
91
+
92
+ export async function initWasm() {
93
+ return ensureInitPromise();
94
+ }
@@ -231,39 +231,6 @@ 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
-
267
234
  /**
268
235
  * @param {Uint8Array} html
269
236
  * @param {any} options
@@ -294,26 +261,6 @@ export function convertBytes(html, options) {
294
261
  }
295
262
  }
296
263
 
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
-
317
264
  /**
318
265
  * Convert HTML to Markdown
319
266
  *
@@ -362,6 +309,11 @@ export function convert(html, options) {
362
309
  }
363
310
  }
364
311
 
312
+ function _assertClass(instance, klass) {
313
+ if (!(instance instanceof klass)) {
314
+ throw new Error(`expected instance of ${klass.name}`);
315
+ }
316
+ }
365
317
  /**
366
318
  * @param {string} html
367
319
  * @param {WasmConversionOptionsHandle} handle
@@ -395,6 +347,60 @@ export function convertWithOptionsHandle(html, handle) {
395
347
  }
396
348
  }
397
349
 
350
+ /**
351
+ * Initialize panic hook for better error messages in the browser
352
+ */
353
+ export function init() {
354
+ wasm.init();
355
+ }
356
+
357
+ /**
358
+ * @param {Uint8Array} html
359
+ * @param {any} options
360
+ * @param {WasmInlineImageConfig | null} [image_config]
361
+ * @returns {WasmHtmlExtraction}
362
+ */
363
+ export function convertBytesWithInlineImages(html, options, image_config) {
364
+ try {
365
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
366
+ let ptr0 = 0;
367
+ if (!isLikeNone(image_config)) {
368
+ _assertClass(image_config, WasmInlineImageConfig);
369
+ ptr0 = image_config.__destroy_into_raw();
370
+ }
371
+ wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
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 WasmHtmlExtraction.__wrap(r0);
379
+ } finally {
380
+ wasm.__wbindgen_add_to_stack_pointer(16);
381
+ }
382
+ }
383
+
384
+ /**
385
+ * @param {any} options
386
+ * @returns {WasmConversionOptionsHandle}
387
+ */
388
+ export function createConversionOptionsHandle(options) {
389
+ try {
390
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
391
+ wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
392
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
393
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
394
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
395
+ if (r2) {
396
+ throw takeObject(r1);
397
+ }
398
+ return WasmConversionOptionsHandle.__wrap(r0);
399
+ } finally {
400
+ wasm.__wbindgen_add_to_stack_pointer(16);
401
+ }
402
+ }
403
+
398
404
  /**
399
405
  * @param {Uint8Array} html
400
406
  * @param {WasmConversionOptionsHandle} handle
@@ -426,13 +432,6 @@ export function convertBytesWithOptionsHandle(html, handle) {
426
432
  }
427
433
  }
428
434
 
429
- /**
430
- * Initialize panic hook for better error messages in the browser
431
- */
432
- export function init() {
433
- wasm.init();
434
- }
435
-
436
435
  /**
437
436
  * @param {string} html
438
437
  * @param {any} options
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.1",
7
+ "version": "2.8.0",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",
@@ -2,12 +2,15 @@
2
2
 
3
3
  High-performance HTML → Markdown conversion powered by Rust. Shipping as a Rust crate, Python package, PHP extension, Ruby gem, Node.js bindings, WebAssembly, and standalone CLI with identical rendering behaviour.
4
4
 
5
- [![Crates.io](https://img.shields.io/crates/v/html-to-markdown-rs.svg)](https://crates.io/crates/html-to-markdown-rs)
5
+ [![Crates.io](https://img.shields.io/crates/v/html-to-markdown.svg)](https://crates.io/crates/html-to-markdown)
6
6
  [![npm (node)](https://badge.fury.io/js/html-to-markdown-node.svg)](https://www.npmjs.com/package/html-to-markdown-node)
7
7
  [![npm (wasm)](https://badge.fury.io/js/html-to-markdown-wasm.svg)](https://www.npmjs.com/package/html-to-markdown-wasm)
8
8
  [![PyPI](https://badge.fury.io/py/html-to-markdown.svg)](https://pypi.org/project/html-to-markdown/)
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
+ [![NuGet](https://img.shields.io/nuget/v/HtmlToMarkdown.svg)](https://www.nuget.org/packages/HtmlToMarkdown/)
12
+ [![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)
13
+ [![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)
11
14
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Goldziher/html-to-markdown/blob/main/LICENSE)
12
15
  [![Discord](https://img.shields.io/badge/Discord-Join%20our%20community-7289da)](https://discord.gg/pXxagNK2zN)
13
16
 
@@ -89,7 +92,7 @@ const markdown = convert(html, {
89
92
  });
90
93
  ```
91
94
 
92
- **Performance:** The shared fixture harness (`task bench:bindings`) now clocks Node, Python, and the Rust CLI at ~1.3–1.4k ops/sec (≈150MB/s) on the 129KB Wikipedia Lists page thanks to the new Buffer/Uint8Array fast paths and release-mode harness. Ruby stays close at ~1.2k ops/sec, PHP lands around 0.3k ops/sec (≈35 MB/s), and WASM hits ~0.85k ops/sec—plenty for browsers, Deno, and edge runtimes.
95
+ **Performance:** The shared fixture harness (`task bench:bindings`) now clocks C# at ~1.4k ops/sec (≈171 MB/s), Go at ~1.3k ops/sec (≈165 MB/s), Node, Python, and the Rust CLI at ~1.3–1.4k ops/sec (≈150 MB/s) on the 129 KB Wikipedia "Lists" page thanks to the new Buffer/Uint8Array fast paths and release-mode harness. Ruby stays close at ~1.2k ops/sec (≈150 MB/s), Java lands at ~1.0k ops/sec (≈126 MB/s), WASM hits ~0.85k ops/sec (≈108 MB/s), and PHP achieves ~0.3k ops/sec (≈35 MB/s)—all providing excellent throughput for production workloads.
93
96
 
94
97
  See the JavaScript guides for full API documentation:
95
98
 
@@ -1,8 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
4
3
  export function convertBytes(html: Uint8Array, options: any): string;
5
- export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
6
4
  /**
7
5
  * Convert HTML to Markdown
8
6
  *
@@ -23,11 +21,13 @@ export function createConversionOptionsHandle(options: any): WasmConversionOptio
23
21
  */
24
22
  export function convert(html: string, options: any): string;
25
23
  export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
26
- export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
27
24
  /**
28
25
  * Initialize panic hook for better error messages in the browser
29
26
  */
30
27
  export function init(): void;
28
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
29
+ export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
30
+ export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
31
31
  export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
32
32
  export class WasmConversionOptionsHandle {
33
33
  free(): void;
@@ -221,39 +221,6 @@ 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
-
257
224
  /**
258
225
  * @param {Uint8Array} html
259
226
  * @param {any} options
@@ -284,26 +251,6 @@ exports.convertBytes = function(html, options) {
284
251
  }
285
252
  };
286
253
 
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
-
307
254
  /**
308
255
  * Convert HTML to Markdown
309
256
  *
@@ -352,6 +299,11 @@ exports.convert = function(html, options) {
352
299
  }
353
300
  };
354
301
 
302
+ function _assertClass(instance, klass) {
303
+ if (!(instance instanceof klass)) {
304
+ throw new Error(`expected instance of ${klass.name}`);
305
+ }
306
+ }
355
307
  /**
356
308
  * @param {string} html
357
309
  * @param {WasmConversionOptionsHandle} handle
@@ -385,6 +337,60 @@ exports.convertWithOptionsHandle = function(html, handle) {
385
337
  }
386
338
  };
387
339
 
340
+ /**
341
+ * Initialize panic hook for better error messages in the browser
342
+ */
343
+ exports.init = function() {
344
+ wasm.init();
345
+ };
346
+
347
+ /**
348
+ * @param {Uint8Array} html
349
+ * @param {any} options
350
+ * @param {WasmInlineImageConfig | null} [image_config]
351
+ * @returns {WasmHtmlExtraction}
352
+ */
353
+ exports.convertBytesWithInlineImages = function(html, options, image_config) {
354
+ try {
355
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
356
+ let ptr0 = 0;
357
+ if (!isLikeNone(image_config)) {
358
+ _assertClass(image_config, WasmInlineImageConfig);
359
+ ptr0 = image_config.__destroy_into_raw();
360
+ }
361
+ wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
362
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
363
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
364
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
365
+ if (r2) {
366
+ throw takeObject(r1);
367
+ }
368
+ return WasmHtmlExtraction.__wrap(r0);
369
+ } finally {
370
+ wasm.__wbindgen_add_to_stack_pointer(16);
371
+ }
372
+ };
373
+
374
+ /**
375
+ * @param {any} options
376
+ * @returns {WasmConversionOptionsHandle}
377
+ */
378
+ exports.createConversionOptionsHandle = function(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
+ }
392
+ };
393
+
388
394
  /**
389
395
  * @param {Uint8Array} html
390
396
  * @param {WasmConversionOptionsHandle} handle
@@ -416,13 +422,6 @@ exports.convertBytesWithOptionsHandle = function(html, handle) {
416
422
  }
417
423
  };
418
424
 
419
- /**
420
- * Initialize panic hook for better error messages in the browser
421
- */
422
- exports.init = function() {
423
- wasm.init();
424
- };
425
-
426
425
  /**
427
426
  * @param {string} html
428
427
  * @param {any} options
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "Na'aman Hirschfeld <nhirschfeld@gmail.com>"
5
5
  ],
6
- "version": "2.7.1",
6
+ "version": "2.8.0",
7
7
  "license": "MIT",
8
8
  "repository": {
9
9
  "type": "git",
@@ -2,12 +2,15 @@
2
2
 
3
3
  High-performance HTML → Markdown conversion powered by Rust. Shipping as a Rust crate, Python package, PHP extension, Ruby gem, Node.js bindings, WebAssembly, and standalone CLI with identical rendering behaviour.
4
4
 
5
- [![Crates.io](https://img.shields.io/crates/v/html-to-markdown-rs.svg)](https://crates.io/crates/html-to-markdown-rs)
5
+ [![Crates.io](https://img.shields.io/crates/v/html-to-markdown.svg)](https://crates.io/crates/html-to-markdown)
6
6
  [![npm (node)](https://badge.fury.io/js/html-to-markdown-node.svg)](https://www.npmjs.com/package/html-to-markdown-node)
7
7
  [![npm (wasm)](https://badge.fury.io/js/html-to-markdown-wasm.svg)](https://www.npmjs.com/package/html-to-markdown-wasm)
8
8
  [![PyPI](https://badge.fury.io/py/html-to-markdown.svg)](https://pypi.org/project/html-to-markdown/)
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
+ [![NuGet](https://img.shields.io/nuget/v/HtmlToMarkdown.svg)](https://www.nuget.org/packages/HtmlToMarkdown/)
12
+ [![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)
13
+ [![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)
11
14
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Goldziher/html-to-markdown/blob/main/LICENSE)
12
15
  [![Discord](https://img.shields.io/badge/Discord-Join%20our%20community-7289da)](https://discord.gg/pXxagNK2zN)
13
16
 
@@ -89,7 +92,7 @@ const markdown = convert(html, {
89
92
  });
90
93
  ```
91
94
 
92
- **Performance:** The shared fixture harness (`task bench:bindings`) now clocks Node, Python, and the Rust CLI at ~1.3–1.4k ops/sec (≈150MB/s) on the 129KB Wikipedia Lists page thanks to the new Buffer/Uint8Array fast paths and release-mode harness. Ruby stays close at ~1.2k ops/sec, PHP lands around 0.3k ops/sec (≈35 MB/s), and WASM hits ~0.85k ops/sec—plenty for browsers, Deno, and edge runtimes.
95
+ **Performance:** The shared fixture harness (`task bench:bindings`) now clocks C# at ~1.4k ops/sec (≈171 MB/s), Go at ~1.3k ops/sec (≈165 MB/s), Node, Python, and the Rust CLI at ~1.3–1.4k ops/sec (≈150 MB/s) on the 129 KB Wikipedia "Lists" page thanks to the new Buffer/Uint8Array fast paths and release-mode harness. Ruby stays close at ~1.2k ops/sec (≈150 MB/s), Java lands at ~1.0k ops/sec (≈126 MB/s), WASM hits ~0.85k ops/sec (≈108 MB/s), and PHP achieves ~0.3k ops/sec (≈35 MB/s)—all providing excellent throughput for production workloads.
93
96
 
94
97
  See the JavaScript guides for full API documentation:
95
98
 
@@ -1,8 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
4
3
  export function convertBytes(html: Uint8Array, options: any): string;
5
- export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
6
4
  /**
7
5
  * Convert HTML to Markdown
8
6
  *
@@ -23,11 +21,13 @@ export function createConversionOptionsHandle(options: any): WasmConversionOptio
23
21
  */
24
22
  export function convert(html: string, options: any): string;
25
23
  export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
26
- export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
27
24
  /**
28
25
  * Initialize panic hook for better error messages in the browser
29
26
  */
30
27
  export function init(): void;
28
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
29
+ export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
30
+ export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
31
31
  export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
32
32
  export class WasmConversionOptionsHandle {
33
33
  free(): void;
@@ -227,39 +227,6 @@ 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
-
263
230
  /**
264
231
  * @param {Uint8Array} html
265
232
  * @param {any} options
@@ -290,26 +257,6 @@ export function convertBytes(html, options) {
290
257
  }
291
258
  }
292
259
 
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
-
313
260
  /**
314
261
  * Convert HTML to Markdown
315
262
  *
@@ -358,6 +305,11 @@ export function convert(html, options) {
358
305
  }
359
306
  }
360
307
 
308
+ function _assertClass(instance, klass) {
309
+ if (!(instance instanceof klass)) {
310
+ throw new Error(`expected instance of ${klass.name}`);
311
+ }
312
+ }
361
313
  /**
362
314
  * @param {string} html
363
315
  * @param {WasmConversionOptionsHandle} handle
@@ -391,6 +343,60 @@ export function convertWithOptionsHandle(html, handle) {
391
343
  }
392
344
  }
393
345
 
346
+ /**
347
+ * Initialize panic hook for better error messages in the browser
348
+ */
349
+ export function init() {
350
+ wasm.init();
351
+ }
352
+
353
+ /**
354
+ * @param {Uint8Array} html
355
+ * @param {any} options
356
+ * @param {WasmInlineImageConfig | null} [image_config]
357
+ * @returns {WasmHtmlExtraction}
358
+ */
359
+ export function convertBytesWithInlineImages(html, options, image_config) {
360
+ try {
361
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
362
+ let ptr0 = 0;
363
+ if (!isLikeNone(image_config)) {
364
+ _assertClass(image_config, WasmInlineImageConfig);
365
+ ptr0 = image_config.__destroy_into_raw();
366
+ }
367
+ wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
368
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
369
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
370
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
371
+ if (r2) {
372
+ throw takeObject(r1);
373
+ }
374
+ return WasmHtmlExtraction.__wrap(r0);
375
+ } finally {
376
+ wasm.__wbindgen_add_to_stack_pointer(16);
377
+ }
378
+ }
379
+
380
+ /**
381
+ * @param {any} options
382
+ * @returns {WasmConversionOptionsHandle}
383
+ */
384
+ export function createConversionOptionsHandle(options) {
385
+ try {
386
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
387
+ wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
388
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
389
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
390
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
391
+ if (r2) {
392
+ throw takeObject(r1);
393
+ }
394
+ return WasmConversionOptionsHandle.__wrap(r0);
395
+ } finally {
396
+ wasm.__wbindgen_add_to_stack_pointer(16);
397
+ }
398
+ }
399
+
394
400
  /**
395
401
  * @param {Uint8Array} html
396
402
  * @param {WasmConversionOptionsHandle} handle
@@ -422,13 +428,6 @@ export function convertBytesWithOptionsHandle(html, handle) {
422
428
  }
423
429
  }
424
430
 
425
- /**
426
- * Initialize panic hook for better error messages in the browser
427
- */
428
- export function init() {
429
- wasm.init();
430
- }
431
-
432
431
  /**
433
432
  * @param {string} html
434
433
  * @param {any} options
@@ -4,7 +4,7 @@
4
4
  "collaborators": [
5
5
  "Na'aman Hirschfeld <nhirschfeld@gmail.com>"
6
6
  ],
7
- "version": "2.7.1",
7
+ "version": "2.8.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.7.1",
3
+ "version": "2.8.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",
@@ -42,7 +42,7 @@
42
42
  "README.md"
43
43
  ],
44
44
  "scripts": {
45
- "build": "wasm-pack build --target bundler --out-dir dist",
45
+ "build": "wasm-pack build --target bundler --out-dir dist && node ./scripts/patch-bundler-entry.js",
46
46
  "build:nodejs": "wasm-pack build --target nodejs --out-dir dist-node",
47
47
  "build:web": "wasm-pack build --target web --out-dir dist-web",
48
48
  "build:all": "pnpm run build && pnpm run build:nodejs && pnpm run build:web && pnpm run cleanup:gitignore",
@@ -53,7 +53,7 @@
53
53
  "clean": "rm -rf dist dist-node dist-web node_modules pkg"
54
54
  },
55
55
  "devDependencies": {
56
- "@types/node": "^24.10.0",
56
+ "@types/node": "^24.10.1",
57
57
  "tsx": "^4.20.6",
58
58
  "vitest": "^4.0.8",
59
59
  "wasm-pack": "^0.13.1"