html-to-markdown-wasm 2.8.2 → 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 +1 -1
- package/dist/README.md +15 -1
- package/dist/html_to_markdown_wasm.d.ts +8 -8
- package/dist/html_to_markdown_wasm_bg.js +83 -83
- package/dist/html_to_markdown_wasm_bg.wasm +0 -0
- package/dist/package.json +1 -1
- package/dist-node/README.md +15 -1
- package/dist-node/html_to_markdown_wasm.d.ts +8 -8
- package/dist-node/html_to_markdown_wasm.js +83 -83
- package/dist-node/html_to_markdown_wasm_bg.wasm +0 -0
- package/dist-node/package.json +1 -1
- package/dist-web/README.md +15 -1
- package/dist-web/html_to_markdown_wasm.d.ts +8 -8
- package/dist-web/html_to_markdown_wasm.js +83 -83
- package/dist-web/html_to_markdown_wasm_bg.wasm +0 -0
- package/dist-web/package.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Runs anywhere: Node.js, Deno, Bun, browsers, and edge runtimes.
|
|
|
15
15
|
[](https://pypi.org/project/html-to-markdown/)
|
|
16
16
|
[](https://packagist.org/packages/goldziher/html-to-markdown)
|
|
17
17
|
[](https://rubygems.org/gems/html-to-markdown)
|
|
18
|
-
[](https://www.nuget.org/packages/HtmlToMarkdown/)
|
|
18
|
+
[](https://www.nuget.org/packages/Goldziher.HtmlToMarkdown/)
|
|
19
19
|
[](https://central.sonatype.com/artifact/io.github.goldziher/html-to-markdown)
|
|
20
20
|
[](https://pkg.go.dev/github.com/Goldziher/html-to-markdown/packages/go/htmltomarkdown)
|
|
21
21
|
[](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
|
[](https://packagist.org/packages/goldziher/html-to-markdown)
|
|
10
10
|
[](https://rubygems.org/gems/html-to-markdown)
|
|
11
11
|
[](https://hex.pm/packages/html_to_markdown)
|
|
12
|
-
[](https://www.nuget.org/packages/HtmlToMarkdown/)
|
|
12
|
+
[](https://www.nuget.org/packages/Goldziher.HtmlToMarkdown/)
|
|
13
13
|
[](https://central.sonatype.com/artifact/io.github.goldziher/html-to-markdown)
|
|
14
14
|
[](https://pkg.go.dev/github.com/Goldziher/html-to-markdown/packages/go/htmltomarkdown)
|
|
15
15
|
[](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,9 +1,9 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export function
|
|
3
|
+
/**
|
|
4
|
+
* Initialize panic hook for better error messages in the browser
|
|
5
|
+
*/
|
|
6
|
+
export function init(): void;
|
|
7
7
|
export function convertBytes(html: Uint8Array, options: any): string;
|
|
8
8
|
/**
|
|
9
9
|
* Convert HTML to Markdown
|
|
@@ -24,11 +24,11 @@ export function convertBytes(html: Uint8Array, options: any): string;
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
export function convert(html: string, options: any): string;
|
|
27
|
+
export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
|
|
28
|
+
export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
|
|
29
|
+
export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
|
|
27
30
|
export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
|
|
28
|
-
|
|
29
|
-
* Initialize panic hook for better error messages in the browser
|
|
30
|
-
*/
|
|
31
|
-
export function init(): void;
|
|
31
|
+
export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
|
|
32
32
|
export class WasmConversionOptionsHandle {
|
|
33
33
|
free(): void;
|
|
34
34
|
[Symbol.dispose](): void;
|
|
@@ -232,71 +232,23 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
232
232
|
return result;
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
|
-
*
|
|
236
|
-
* @returns {WasmConversionOptionsHandle}
|
|
237
|
-
*/
|
|
238
|
-
export function createConversionOptionsHandle(options) {
|
|
239
|
-
try {
|
|
240
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
241
|
-
wasm.createConversionOptionsHandle(retptr, 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
|
-
if (r2) {
|
|
246
|
-
throw takeObject(r1);
|
|
247
|
-
}
|
|
248
|
-
return WasmConversionOptionsHandle.__wrap(r0);
|
|
249
|
-
} finally {
|
|
250
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function _assertClass(instance, klass) {
|
|
255
|
-
if (!(instance instanceof klass)) {
|
|
256
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* @param {string} html
|
|
261
|
-
* @param {any} options
|
|
262
|
-
* @param {WasmInlineImageConfig | null} [image_config]
|
|
263
|
-
* @returns {WasmHtmlExtraction}
|
|
235
|
+
* Initialize panic hook for better error messages in the browser
|
|
264
236
|
*/
|
|
265
|
-
export function
|
|
266
|
-
|
|
267
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
268
|
-
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
269
|
-
const len0 = WASM_VECTOR_LEN;
|
|
270
|
-
let ptr1 = 0;
|
|
271
|
-
if (!isLikeNone(image_config)) {
|
|
272
|
-
_assertClass(image_config, WasmInlineImageConfig);
|
|
273
|
-
ptr1 = image_config.__destroy_into_raw();
|
|
274
|
-
}
|
|
275
|
-
wasm.convertWithInlineImages(retptr, ptr0, len0, addHeapObject(options), ptr1);
|
|
276
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
277
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
278
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
279
|
-
if (r2) {
|
|
280
|
-
throw takeObject(r1);
|
|
281
|
-
}
|
|
282
|
-
return WasmHtmlExtraction.__wrap(r0);
|
|
283
|
-
} finally {
|
|
284
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
285
|
-
}
|
|
237
|
+
export function init() {
|
|
238
|
+
wasm.init();
|
|
286
239
|
}
|
|
287
240
|
|
|
288
241
|
/**
|
|
289
242
|
* @param {Uint8Array} html
|
|
290
|
-
* @param {
|
|
243
|
+
* @param {any} options
|
|
291
244
|
* @returns {string}
|
|
292
245
|
*/
|
|
293
|
-
export function
|
|
246
|
+
export function convertBytes(html, options) {
|
|
294
247
|
let deferred2_0;
|
|
295
248
|
let deferred2_1;
|
|
296
249
|
try {
|
|
297
250
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
298
|
-
|
|
299
|
-
wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
|
|
251
|
+
wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
|
|
300
252
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
301
253
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
302
254
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -317,19 +269,34 @@ export function convertBytesWithOptionsHandle(html, handle) {
|
|
|
317
269
|
}
|
|
318
270
|
|
|
319
271
|
/**
|
|
272
|
+
* Convert HTML to Markdown
|
|
273
|
+
*
|
|
274
|
+
* # Arguments
|
|
275
|
+
*
|
|
276
|
+
* * `html` - The HTML string to convert
|
|
277
|
+
* * `options` - Optional conversion options (as a JavaScript object)
|
|
278
|
+
*
|
|
279
|
+
* # Example
|
|
280
|
+
*
|
|
281
|
+
* ```javascript
|
|
282
|
+
* import { convert } from 'html-to-markdown-wasm';
|
|
283
|
+
*
|
|
284
|
+
* const html = '<h1>Hello World</h1>';
|
|
285
|
+
* const markdown = convert(html);
|
|
286
|
+
* console.log(markdown); // # Hello World
|
|
287
|
+
* ```
|
|
320
288
|
* @param {string} html
|
|
321
|
-
* @param {
|
|
289
|
+
* @param {any} options
|
|
322
290
|
* @returns {string}
|
|
323
291
|
*/
|
|
324
|
-
export function
|
|
292
|
+
export function convert(html, options) {
|
|
325
293
|
let deferred3_0;
|
|
326
294
|
let deferred3_1;
|
|
327
295
|
try {
|
|
328
296
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
329
297
|
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
330
298
|
const len0 = WASM_VECTOR_LEN;
|
|
331
|
-
|
|
332
|
-
wasm.convertWithOptionsHandle(retptr, ptr0, len0, handle.__wbg_ptr);
|
|
299
|
+
wasm.convert(retptr, ptr0, len0, addHeapObject(options));
|
|
333
300
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
334
301
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
335
302
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -349,17 +316,52 @@ export function convertWithOptionsHandle(html, handle) {
|
|
|
349
316
|
}
|
|
350
317
|
}
|
|
351
318
|
|
|
319
|
+
function _assertClass(instance, klass) {
|
|
320
|
+
if (!(instance instanceof klass)) {
|
|
321
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
352
324
|
/**
|
|
353
|
-
* @param {
|
|
325
|
+
* @param {string} html
|
|
354
326
|
* @param {any} options
|
|
327
|
+
* @param {WasmInlineImageConfig | null} [image_config]
|
|
328
|
+
* @returns {WasmHtmlExtraction}
|
|
329
|
+
*/
|
|
330
|
+
export function convertWithInlineImages(html, options, image_config) {
|
|
331
|
+
try {
|
|
332
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
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);
|
|
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
|
+
if (r2) {
|
|
345
|
+
throw takeObject(r1);
|
|
346
|
+
}
|
|
347
|
+
return WasmHtmlExtraction.__wrap(r0);
|
|
348
|
+
} finally {
|
|
349
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* @param {Uint8Array} html
|
|
355
|
+
* @param {WasmConversionOptionsHandle} handle
|
|
355
356
|
* @returns {string}
|
|
356
357
|
*/
|
|
357
|
-
export function
|
|
358
|
+
export function convertBytesWithOptionsHandle(html, handle) {
|
|
358
359
|
let deferred2_0;
|
|
359
360
|
let deferred2_1;
|
|
360
361
|
try {
|
|
361
362
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
362
|
-
|
|
363
|
+
_assertClass(handle, WasmConversionOptionsHandle);
|
|
364
|
+
wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
|
|
363
365
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
364
366
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
365
367
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -380,34 +382,19 @@ export function convertBytes(html, options) {
|
|
|
380
382
|
}
|
|
381
383
|
|
|
382
384
|
/**
|
|
383
|
-
* Convert HTML to Markdown
|
|
384
|
-
*
|
|
385
|
-
* # Arguments
|
|
386
|
-
*
|
|
387
|
-
* * `html` - The HTML string to convert
|
|
388
|
-
* * `options` - Optional conversion options (as a JavaScript object)
|
|
389
|
-
*
|
|
390
|
-
* # Example
|
|
391
|
-
*
|
|
392
|
-
* ```javascript
|
|
393
|
-
* import { convert } from 'html-to-markdown-wasm';
|
|
394
|
-
*
|
|
395
|
-
* const html = '<h1>Hello World</h1>';
|
|
396
|
-
* const markdown = convert(html);
|
|
397
|
-
* console.log(markdown); // # Hello World
|
|
398
|
-
* ```
|
|
399
385
|
* @param {string} html
|
|
400
|
-
* @param {
|
|
386
|
+
* @param {WasmConversionOptionsHandle} handle
|
|
401
387
|
* @returns {string}
|
|
402
388
|
*/
|
|
403
|
-
export function
|
|
389
|
+
export function convertWithOptionsHandle(html, handle) {
|
|
404
390
|
let deferred3_0;
|
|
405
391
|
let deferred3_1;
|
|
406
392
|
try {
|
|
407
393
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
408
394
|
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
409
395
|
const len0 = WASM_VECTOR_LEN;
|
|
410
|
-
|
|
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);
|
|
@@ -455,10 +442,23 @@ export function convertBytesWithInlineImages(html, options, image_config) {
|
|
|
455
442
|
}
|
|
456
443
|
|
|
457
444
|
/**
|
|
458
|
-
*
|
|
445
|
+
* @param {any} options
|
|
446
|
+
* @returns {WasmConversionOptionsHandle}
|
|
459
447
|
*/
|
|
460
|
-
export function
|
|
461
|
-
|
|
448
|
+
export function createConversionOptionsHandle(options) {
|
|
449
|
+
try {
|
|
450
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
451
|
+
wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
|
|
452
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
453
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
454
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
455
|
+
if (r2) {
|
|
456
|
+
throw takeObject(r1);
|
|
457
|
+
}
|
|
458
|
+
return WasmConversionOptionsHandle.__wrap(r0);
|
|
459
|
+
} finally {
|
|
460
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
461
|
+
}
|
|
462
462
|
}
|
|
463
463
|
|
|
464
464
|
const WasmConversionOptionsHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
Binary file
|
package/dist/package.json
CHANGED
package/dist-node/README.md
CHANGED
|
@@ -9,7 +9,7 @@ High-performance HTML → Markdown conversion powered by Rust. Shipping as a Rus
|
|
|
9
9
|
[](https://packagist.org/packages/goldziher/html-to-markdown)
|
|
10
10
|
[](https://rubygems.org/gems/html-to-markdown)
|
|
11
11
|
[](https://hex.pm/packages/html_to_markdown)
|
|
12
|
-
[](https://www.nuget.org/packages/HtmlToMarkdown/)
|
|
12
|
+
[](https://www.nuget.org/packages/Goldziher.HtmlToMarkdown/)
|
|
13
13
|
[](https://central.sonatype.com/artifact/io.github.goldziher/html-to-markdown)
|
|
14
14
|
[](https://pkg.go.dev/github.com/Goldziher/html-to-markdown/packages/go/htmltomarkdown)
|
|
15
15
|
[](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,9 +1,9 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export function
|
|
3
|
+
/**
|
|
4
|
+
* Initialize panic hook for better error messages in the browser
|
|
5
|
+
*/
|
|
6
|
+
export function init(): void;
|
|
7
7
|
export function convertBytes(html: Uint8Array, options: any): string;
|
|
8
8
|
/**
|
|
9
9
|
* Convert HTML to Markdown
|
|
@@ -24,11 +24,11 @@ export function convertBytes(html: Uint8Array, options: any): string;
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
export function convert(html: string, options: any): string;
|
|
27
|
+
export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
|
|
28
|
+
export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
|
|
29
|
+
export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
|
|
27
30
|
export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
|
|
28
|
-
|
|
29
|
-
* Initialize panic hook for better error messages in the browser
|
|
30
|
-
*/
|
|
31
|
-
export function init(): void;
|
|
31
|
+
export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
|
|
32
32
|
export class WasmConversionOptionsHandle {
|
|
33
33
|
free(): void;
|
|
34
34
|
[Symbol.dispose](): void;
|
|
@@ -222,71 +222,23 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
222
222
|
return result;
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
225
|
-
*
|
|
226
|
-
* @returns {WasmConversionOptionsHandle}
|
|
227
|
-
*/
|
|
228
|
-
exports.createConversionOptionsHandle = function(options) {
|
|
229
|
-
try {
|
|
230
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
231
|
-
wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
|
|
232
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
233
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
234
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
235
|
-
if (r2) {
|
|
236
|
-
throw takeObject(r1);
|
|
237
|
-
}
|
|
238
|
-
return WasmConversionOptionsHandle.__wrap(r0);
|
|
239
|
-
} finally {
|
|
240
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
function _assertClass(instance, klass) {
|
|
245
|
-
if (!(instance instanceof klass)) {
|
|
246
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* @param {string} html
|
|
251
|
-
* @param {any} options
|
|
252
|
-
* @param {WasmInlineImageConfig | null} [image_config]
|
|
253
|
-
* @returns {WasmHtmlExtraction}
|
|
225
|
+
* Initialize panic hook for better error messages in the browser
|
|
254
226
|
*/
|
|
255
|
-
exports.
|
|
256
|
-
|
|
257
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
258
|
-
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
259
|
-
const len0 = WASM_VECTOR_LEN;
|
|
260
|
-
let ptr1 = 0;
|
|
261
|
-
if (!isLikeNone(image_config)) {
|
|
262
|
-
_assertClass(image_config, WasmInlineImageConfig);
|
|
263
|
-
ptr1 = image_config.__destroy_into_raw();
|
|
264
|
-
}
|
|
265
|
-
wasm.convertWithInlineImages(retptr, ptr0, len0, addHeapObject(options), ptr1);
|
|
266
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
267
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
268
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
269
|
-
if (r2) {
|
|
270
|
-
throw takeObject(r1);
|
|
271
|
-
}
|
|
272
|
-
return WasmHtmlExtraction.__wrap(r0);
|
|
273
|
-
} finally {
|
|
274
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
275
|
-
}
|
|
227
|
+
exports.init = function() {
|
|
228
|
+
wasm.init();
|
|
276
229
|
};
|
|
277
230
|
|
|
278
231
|
/**
|
|
279
232
|
* @param {Uint8Array} html
|
|
280
|
-
* @param {
|
|
233
|
+
* @param {any} options
|
|
281
234
|
* @returns {string}
|
|
282
235
|
*/
|
|
283
|
-
exports.
|
|
236
|
+
exports.convertBytes = function(html, options) {
|
|
284
237
|
let deferred2_0;
|
|
285
238
|
let deferred2_1;
|
|
286
239
|
try {
|
|
287
240
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
288
|
-
|
|
289
|
-
wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
|
|
241
|
+
wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
|
|
290
242
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
291
243
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
292
244
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -307,19 +259,34 @@ exports.convertBytesWithOptionsHandle = function(html, handle) {
|
|
|
307
259
|
};
|
|
308
260
|
|
|
309
261
|
/**
|
|
262
|
+
* Convert HTML to Markdown
|
|
263
|
+
*
|
|
264
|
+
* # Arguments
|
|
265
|
+
*
|
|
266
|
+
* * `html` - The HTML string to convert
|
|
267
|
+
* * `options` - Optional conversion options (as a JavaScript object)
|
|
268
|
+
*
|
|
269
|
+
* # Example
|
|
270
|
+
*
|
|
271
|
+
* ```javascript
|
|
272
|
+
* import { convert } from 'html-to-markdown-wasm';
|
|
273
|
+
*
|
|
274
|
+
* const html = '<h1>Hello World</h1>';
|
|
275
|
+
* const markdown = convert(html);
|
|
276
|
+
* console.log(markdown); // # Hello World
|
|
277
|
+
* ```
|
|
310
278
|
* @param {string} html
|
|
311
|
-
* @param {
|
|
279
|
+
* @param {any} options
|
|
312
280
|
* @returns {string}
|
|
313
281
|
*/
|
|
314
|
-
exports.
|
|
282
|
+
exports.convert = function(html, options) {
|
|
315
283
|
let deferred3_0;
|
|
316
284
|
let deferred3_1;
|
|
317
285
|
try {
|
|
318
286
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
319
287
|
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
320
288
|
const len0 = WASM_VECTOR_LEN;
|
|
321
|
-
|
|
322
|
-
wasm.convertWithOptionsHandle(retptr, ptr0, len0, handle.__wbg_ptr);
|
|
289
|
+
wasm.convert(retptr, ptr0, len0, addHeapObject(options));
|
|
323
290
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
324
291
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
325
292
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -339,17 +306,52 @@ exports.convertWithOptionsHandle = function(html, handle) {
|
|
|
339
306
|
}
|
|
340
307
|
};
|
|
341
308
|
|
|
309
|
+
function _assertClass(instance, klass) {
|
|
310
|
+
if (!(instance instanceof klass)) {
|
|
311
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
342
314
|
/**
|
|
343
|
-
* @param {
|
|
315
|
+
* @param {string} html
|
|
344
316
|
* @param {any} options
|
|
317
|
+
* @param {WasmInlineImageConfig | null} [image_config]
|
|
318
|
+
* @returns {WasmHtmlExtraction}
|
|
319
|
+
*/
|
|
320
|
+
exports.convertWithInlineImages = function(html, options, image_config) {
|
|
321
|
+
try {
|
|
322
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
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);
|
|
331
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
332
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
333
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
334
|
+
if (r2) {
|
|
335
|
+
throw takeObject(r1);
|
|
336
|
+
}
|
|
337
|
+
return WasmHtmlExtraction.__wrap(r0);
|
|
338
|
+
} finally {
|
|
339
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @param {Uint8Array} html
|
|
345
|
+
* @param {WasmConversionOptionsHandle} handle
|
|
345
346
|
* @returns {string}
|
|
346
347
|
*/
|
|
347
|
-
exports.
|
|
348
|
+
exports.convertBytesWithOptionsHandle = function(html, handle) {
|
|
348
349
|
let deferred2_0;
|
|
349
350
|
let deferred2_1;
|
|
350
351
|
try {
|
|
351
352
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
352
|
-
|
|
353
|
+
_assertClass(handle, WasmConversionOptionsHandle);
|
|
354
|
+
wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
|
|
353
355
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
354
356
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
355
357
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -370,34 +372,19 @@ exports.convertBytes = function(html, options) {
|
|
|
370
372
|
};
|
|
371
373
|
|
|
372
374
|
/**
|
|
373
|
-
* Convert HTML to Markdown
|
|
374
|
-
*
|
|
375
|
-
* # Arguments
|
|
376
|
-
*
|
|
377
|
-
* * `html` - The HTML string to convert
|
|
378
|
-
* * `options` - Optional conversion options (as a JavaScript object)
|
|
379
|
-
*
|
|
380
|
-
* # Example
|
|
381
|
-
*
|
|
382
|
-
* ```javascript
|
|
383
|
-
* import { convert } from 'html-to-markdown-wasm';
|
|
384
|
-
*
|
|
385
|
-
* const html = '<h1>Hello World</h1>';
|
|
386
|
-
* const markdown = convert(html);
|
|
387
|
-
* console.log(markdown); // # Hello World
|
|
388
|
-
* ```
|
|
389
375
|
* @param {string} html
|
|
390
|
-
* @param {
|
|
376
|
+
* @param {WasmConversionOptionsHandle} handle
|
|
391
377
|
* @returns {string}
|
|
392
378
|
*/
|
|
393
|
-
exports.
|
|
379
|
+
exports.convertWithOptionsHandle = function(html, handle) {
|
|
394
380
|
let deferred3_0;
|
|
395
381
|
let deferred3_1;
|
|
396
382
|
try {
|
|
397
383
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
398
384
|
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
399
385
|
const len0 = WASM_VECTOR_LEN;
|
|
400
|
-
|
|
386
|
+
_assertClass(handle, WasmConversionOptionsHandle);
|
|
387
|
+
wasm.convertWithOptionsHandle(retptr, ptr0, len0, handle.__wbg_ptr);
|
|
401
388
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
402
389
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
403
390
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -445,10 +432,23 @@ exports.convertBytesWithInlineImages = function(html, options, image_config) {
|
|
|
445
432
|
};
|
|
446
433
|
|
|
447
434
|
/**
|
|
448
|
-
*
|
|
435
|
+
* @param {any} options
|
|
436
|
+
* @returns {WasmConversionOptionsHandle}
|
|
449
437
|
*/
|
|
450
|
-
exports.
|
|
451
|
-
|
|
438
|
+
exports.createConversionOptionsHandle = function(options) {
|
|
439
|
+
try {
|
|
440
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
441
|
+
wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
|
|
442
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
443
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
444
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
445
|
+
if (r2) {
|
|
446
|
+
throw takeObject(r1);
|
|
447
|
+
}
|
|
448
|
+
return WasmConversionOptionsHandle.__wrap(r0);
|
|
449
|
+
} finally {
|
|
450
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
451
|
+
}
|
|
452
452
|
};
|
|
453
453
|
|
|
454
454
|
const WasmConversionOptionsHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
Binary file
|
package/dist-node/package.json
CHANGED
package/dist-web/README.md
CHANGED
|
@@ -9,7 +9,7 @@ High-performance HTML → Markdown conversion powered by Rust. Shipping as a Rus
|
|
|
9
9
|
[](https://packagist.org/packages/goldziher/html-to-markdown)
|
|
10
10
|
[](https://rubygems.org/gems/html-to-markdown)
|
|
11
11
|
[](https://hex.pm/packages/html_to_markdown)
|
|
12
|
-
[](https://www.nuget.org/packages/HtmlToMarkdown/)
|
|
12
|
+
[](https://www.nuget.org/packages/Goldziher.HtmlToMarkdown/)
|
|
13
13
|
[](https://central.sonatype.com/artifact/io.github.goldziher/html-to-markdown)
|
|
14
14
|
[](https://pkg.go.dev/github.com/Goldziher/html-to-markdown/packages/go/htmltomarkdown)
|
|
15
15
|
[](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,9 +1,9 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export function
|
|
3
|
+
/**
|
|
4
|
+
* Initialize panic hook for better error messages in the browser
|
|
5
|
+
*/
|
|
6
|
+
export function init(): void;
|
|
7
7
|
export function convertBytes(html: Uint8Array, options: any): string;
|
|
8
8
|
/**
|
|
9
9
|
* Convert HTML to Markdown
|
|
@@ -24,11 +24,11 @@ export function convertBytes(html: Uint8Array, options: any): string;
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
export function convert(html: string, options: any): string;
|
|
27
|
+
export function convertWithInlineImages(html: string, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
|
|
28
|
+
export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
|
|
29
|
+
export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
|
|
27
30
|
export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
|
|
28
|
-
|
|
29
|
-
* Initialize panic hook for better error messages in the browser
|
|
30
|
-
*/
|
|
31
|
-
export function init(): void;
|
|
31
|
+
export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
|
|
32
32
|
export class WasmConversionOptionsHandle {
|
|
33
33
|
free(): void;
|
|
34
34
|
[Symbol.dispose](): void;
|
|
@@ -228,71 +228,23 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
228
228
|
return result;
|
|
229
229
|
}
|
|
230
230
|
/**
|
|
231
|
-
*
|
|
232
|
-
* @returns {WasmConversionOptionsHandle}
|
|
233
|
-
*/
|
|
234
|
-
export function createConversionOptionsHandle(options) {
|
|
235
|
-
try {
|
|
236
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
237
|
-
wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
|
|
238
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
239
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
240
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
241
|
-
if (r2) {
|
|
242
|
-
throw takeObject(r1);
|
|
243
|
-
}
|
|
244
|
-
return WasmConversionOptionsHandle.__wrap(r0);
|
|
245
|
-
} finally {
|
|
246
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function _assertClass(instance, klass) {
|
|
251
|
-
if (!(instance instanceof klass)) {
|
|
252
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* @param {string} html
|
|
257
|
-
* @param {any} options
|
|
258
|
-
* @param {WasmInlineImageConfig | null} [image_config]
|
|
259
|
-
* @returns {WasmHtmlExtraction}
|
|
231
|
+
* Initialize panic hook for better error messages in the browser
|
|
260
232
|
*/
|
|
261
|
-
export function
|
|
262
|
-
|
|
263
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
264
|
-
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
265
|
-
const len0 = WASM_VECTOR_LEN;
|
|
266
|
-
let ptr1 = 0;
|
|
267
|
-
if (!isLikeNone(image_config)) {
|
|
268
|
-
_assertClass(image_config, WasmInlineImageConfig);
|
|
269
|
-
ptr1 = image_config.__destroy_into_raw();
|
|
270
|
-
}
|
|
271
|
-
wasm.convertWithInlineImages(retptr, ptr0, len0, addHeapObject(options), ptr1);
|
|
272
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
273
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
274
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
275
|
-
if (r2) {
|
|
276
|
-
throw takeObject(r1);
|
|
277
|
-
}
|
|
278
|
-
return WasmHtmlExtraction.__wrap(r0);
|
|
279
|
-
} finally {
|
|
280
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
281
|
-
}
|
|
233
|
+
export function init() {
|
|
234
|
+
wasm.init();
|
|
282
235
|
}
|
|
283
236
|
|
|
284
237
|
/**
|
|
285
238
|
* @param {Uint8Array} html
|
|
286
|
-
* @param {
|
|
239
|
+
* @param {any} options
|
|
287
240
|
* @returns {string}
|
|
288
241
|
*/
|
|
289
|
-
export function
|
|
242
|
+
export function convertBytes(html, options) {
|
|
290
243
|
let deferred2_0;
|
|
291
244
|
let deferred2_1;
|
|
292
245
|
try {
|
|
293
246
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
294
|
-
|
|
295
|
-
wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
|
|
247
|
+
wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
|
|
296
248
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
297
249
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
298
250
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -313,19 +265,34 @@ export function convertBytesWithOptionsHandle(html, handle) {
|
|
|
313
265
|
}
|
|
314
266
|
|
|
315
267
|
/**
|
|
268
|
+
* Convert HTML to Markdown
|
|
269
|
+
*
|
|
270
|
+
* # Arguments
|
|
271
|
+
*
|
|
272
|
+
* * `html` - The HTML string to convert
|
|
273
|
+
* * `options` - Optional conversion options (as a JavaScript object)
|
|
274
|
+
*
|
|
275
|
+
* # Example
|
|
276
|
+
*
|
|
277
|
+
* ```javascript
|
|
278
|
+
* import { convert } from 'html-to-markdown-wasm';
|
|
279
|
+
*
|
|
280
|
+
* const html = '<h1>Hello World</h1>';
|
|
281
|
+
* const markdown = convert(html);
|
|
282
|
+
* console.log(markdown); // # Hello World
|
|
283
|
+
* ```
|
|
316
284
|
* @param {string} html
|
|
317
|
-
* @param {
|
|
285
|
+
* @param {any} options
|
|
318
286
|
* @returns {string}
|
|
319
287
|
*/
|
|
320
|
-
export function
|
|
288
|
+
export function convert(html, options) {
|
|
321
289
|
let deferred3_0;
|
|
322
290
|
let deferred3_1;
|
|
323
291
|
try {
|
|
324
292
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
325
293
|
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
326
294
|
const len0 = WASM_VECTOR_LEN;
|
|
327
|
-
|
|
328
|
-
wasm.convertWithOptionsHandle(retptr, ptr0, len0, handle.__wbg_ptr);
|
|
295
|
+
wasm.convert(retptr, ptr0, len0, addHeapObject(options));
|
|
329
296
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
330
297
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
331
298
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -345,17 +312,52 @@ export function convertWithOptionsHandle(html, handle) {
|
|
|
345
312
|
}
|
|
346
313
|
}
|
|
347
314
|
|
|
315
|
+
function _assertClass(instance, klass) {
|
|
316
|
+
if (!(instance instanceof klass)) {
|
|
317
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
348
320
|
/**
|
|
349
|
-
* @param {
|
|
321
|
+
* @param {string} html
|
|
350
322
|
* @param {any} options
|
|
323
|
+
* @param {WasmInlineImageConfig | null} [image_config]
|
|
324
|
+
* @returns {WasmHtmlExtraction}
|
|
325
|
+
*/
|
|
326
|
+
export function convertWithInlineImages(html, options, image_config) {
|
|
327
|
+
try {
|
|
328
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
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);
|
|
337
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
338
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
339
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
340
|
+
if (r2) {
|
|
341
|
+
throw takeObject(r1);
|
|
342
|
+
}
|
|
343
|
+
return WasmHtmlExtraction.__wrap(r0);
|
|
344
|
+
} finally {
|
|
345
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* @param {Uint8Array} html
|
|
351
|
+
* @param {WasmConversionOptionsHandle} handle
|
|
351
352
|
* @returns {string}
|
|
352
353
|
*/
|
|
353
|
-
export function
|
|
354
|
+
export function convertBytesWithOptionsHandle(html, handle) {
|
|
354
355
|
let deferred2_0;
|
|
355
356
|
let deferred2_1;
|
|
356
357
|
try {
|
|
357
358
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
358
|
-
|
|
359
|
+
_assertClass(handle, WasmConversionOptionsHandle);
|
|
360
|
+
wasm.convertBytesWithOptionsHandle(retptr, addHeapObject(html), handle.__wbg_ptr);
|
|
359
361
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
360
362
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
361
363
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -376,34 +378,19 @@ export function convertBytes(html, options) {
|
|
|
376
378
|
}
|
|
377
379
|
|
|
378
380
|
/**
|
|
379
|
-
* Convert HTML to Markdown
|
|
380
|
-
*
|
|
381
|
-
* # Arguments
|
|
382
|
-
*
|
|
383
|
-
* * `html` - The HTML string to convert
|
|
384
|
-
* * `options` - Optional conversion options (as a JavaScript object)
|
|
385
|
-
*
|
|
386
|
-
* # Example
|
|
387
|
-
*
|
|
388
|
-
* ```javascript
|
|
389
|
-
* import { convert } from 'html-to-markdown-wasm';
|
|
390
|
-
*
|
|
391
|
-
* const html = '<h1>Hello World</h1>';
|
|
392
|
-
* const markdown = convert(html);
|
|
393
|
-
* console.log(markdown); // # Hello World
|
|
394
|
-
* ```
|
|
395
381
|
* @param {string} html
|
|
396
|
-
* @param {
|
|
382
|
+
* @param {WasmConversionOptionsHandle} handle
|
|
397
383
|
* @returns {string}
|
|
398
384
|
*/
|
|
399
|
-
export function
|
|
385
|
+
export function convertWithOptionsHandle(html, handle) {
|
|
400
386
|
let deferred3_0;
|
|
401
387
|
let deferred3_1;
|
|
402
388
|
try {
|
|
403
389
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
404
390
|
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
405
391
|
const len0 = WASM_VECTOR_LEN;
|
|
406
|
-
|
|
392
|
+
_assertClass(handle, WasmConversionOptionsHandle);
|
|
393
|
+
wasm.convertWithOptionsHandle(retptr, ptr0, len0, handle.__wbg_ptr);
|
|
407
394
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
408
395
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
409
396
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -451,10 +438,23 @@ export function convertBytesWithInlineImages(html, options, image_config) {
|
|
|
451
438
|
}
|
|
452
439
|
|
|
453
440
|
/**
|
|
454
|
-
*
|
|
441
|
+
* @param {any} options
|
|
442
|
+
* @returns {WasmConversionOptionsHandle}
|
|
455
443
|
*/
|
|
456
|
-
export function
|
|
457
|
-
|
|
444
|
+
export function createConversionOptionsHandle(options) {
|
|
445
|
+
try {
|
|
446
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
447
|
+
wasm.createConversionOptionsHandle(retptr, addHeapObject(options));
|
|
448
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
449
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
450
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
451
|
+
if (r2) {
|
|
452
|
+
throw takeObject(r1);
|
|
453
|
+
}
|
|
454
|
+
return WasmConversionOptionsHandle.__wrap(r0);
|
|
455
|
+
} finally {
|
|
456
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
457
|
+
}
|
|
458
458
|
}
|
|
459
459
|
|
|
460
460
|
const WasmConversionOptionsHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
Binary file
|
package/dist-web/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-to-markdown-wasm",
|
|
3
|
-
"version": "2.
|
|
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.
|
|
58
|
+
"vitest": "^4.0.11",
|
|
59
59
|
"wasm-pack": "^0.13.1"
|
|
60
60
|
},
|
|
61
61
|
"publishConfig": {
|