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