html-to-markdown-wasm 2.11.1 → 2.11.4
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 +2 -0
- package/dist/html_to_markdown_wasm.d.ts +57 -7
- package/dist/html_to_markdown_wasm_bg.js +11 -7
- 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 +57 -7
- package/dist-node/html_to_markdown_wasm.js +11 -7
- 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 +57 -7
- package/dist-web/html_to_markdown_wasm.js +11 -7
- package/dist-web/html_to_markdown_wasm_bg.wasm +0 -0
- package/dist-web/package.json +1 -1
- package/package.json +66 -66
package/README.md
CHANGED
|
@@ -97,6 +97,8 @@ console.log(markdown);
|
|
|
97
97
|
|
|
98
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
99
|
|
|
100
|
+
Need a reference setup? Check out the Rollup example under [`examples/wasm-rollup`](https://github.com/Goldziher/html-to-markdown/blob/main/examples/wasm-rollup), which shows how to bundle the WASM artifact, await `wasmReady`, and render the Markdown output in a browser extension–style environment.
|
|
101
|
+
|
|
100
102
|
### Reusing Options Handles
|
|
101
103
|
|
|
102
104
|
```ts
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export class WasmConversionOptionsHandle {
|
|
5
5
|
free(): void;
|
|
6
6
|
[Symbol.dispose](): void;
|
|
7
|
-
constructor(options
|
|
7
|
+
constructor(options?: WasmConversionOptions | null);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export class WasmHtmlExtraction {
|
|
@@ -20,7 +20,7 @@ export class WasmInlineImage {
|
|
|
20
20
|
private constructor();
|
|
21
21
|
free(): void;
|
|
22
22
|
[Symbol.dispose](): void;
|
|
23
|
-
readonly attributes:
|
|
23
|
+
readonly attributes: Record<string, string>;
|
|
24
24
|
readonly dimensions: Uint32Array | undefined;
|
|
25
25
|
readonly description: string | undefined;
|
|
26
26
|
readonly data: Uint8Array;
|
|
@@ -64,19 +64,19 @@ export class WasmInlineImageWarning {
|
|
|
64
64
|
* console.log(markdown); // # Hello World
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
|
-
export function convert(html: string, options
|
|
67
|
+
export function convert(html: string, options?: WasmConversionOptions | null): string;
|
|
68
68
|
|
|
69
|
-
export function convertBytes(html: Uint8Array, options
|
|
69
|
+
export function convertBytes(html: Uint8Array, options?: WasmConversionOptions | null): string;
|
|
70
70
|
|
|
71
|
-
export function convertBytesWithInlineImages(html: Uint8Array, options
|
|
71
|
+
export function convertBytesWithInlineImages(html: Uint8Array, options?: WasmConversionOptions | null, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
|
|
72
72
|
|
|
73
73
|
export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
|
|
74
74
|
|
|
75
|
-
export function convertWithInlineImages(html: string, options
|
|
75
|
+
export function convertWithInlineImages(html: string, options?: WasmConversionOptions | null, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
|
|
76
76
|
|
|
77
77
|
export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
|
|
78
78
|
|
|
79
|
-
export function createConversionOptionsHandle(options
|
|
79
|
+
export function createConversionOptionsHandle(options?: WasmConversionOptions | null): WasmConversionOptionsHandle;
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* Initialize panic hook for better error messages in the browser
|
|
@@ -85,3 +85,53 @@ export function init(): void;
|
|
|
85
85
|
|
|
86
86
|
export declare function initWasm(): Promise<void>;
|
|
87
87
|
export declare const wasmReady: Promise<void>;
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
export type WasmHeadingStyle = "underlined" | "atx" | "atxClosed";
|
|
91
|
+
export type WasmListIndentType = "spaces" | "tabs";
|
|
92
|
+
export type WasmWhitespaceMode = "normalized" | "strict";
|
|
93
|
+
export type WasmNewlineStyle = "spaces" | "backslash";
|
|
94
|
+
export type WasmCodeBlockStyle = "indented" | "backticks" | "tildes";
|
|
95
|
+
export type WasmHighlightStyle = "doubleEqual" | "html" | "bold" | "none";
|
|
96
|
+
export type WasmPreprocessingPreset = "minimal" | "standard" | "aggressive";
|
|
97
|
+
|
|
98
|
+
export interface WasmPreprocessingOptions {
|
|
99
|
+
enabled?: boolean;
|
|
100
|
+
preset?: WasmPreprocessingPreset;
|
|
101
|
+
removeNavigation?: boolean;
|
|
102
|
+
removeForms?: boolean;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface WasmConversionOptions {
|
|
106
|
+
headingStyle?: WasmHeadingStyle;
|
|
107
|
+
listIndentType?: WasmListIndentType;
|
|
108
|
+
listIndentWidth?: number;
|
|
109
|
+
bullets?: string;
|
|
110
|
+
strongEmSymbol?: string;
|
|
111
|
+
escapeAsterisks?: boolean;
|
|
112
|
+
escapeUnderscores?: boolean;
|
|
113
|
+
escapeMisc?: boolean;
|
|
114
|
+
escapeAscii?: boolean;
|
|
115
|
+
codeLanguage?: string;
|
|
116
|
+
autolinks?: boolean;
|
|
117
|
+
defaultTitle?: boolean;
|
|
118
|
+
brInTables?: boolean;
|
|
119
|
+
hocrSpatialTables?: boolean;
|
|
120
|
+
highlightStyle?: WasmHighlightStyle;
|
|
121
|
+
extractMetadata?: boolean;
|
|
122
|
+
whitespaceMode?: WasmWhitespaceMode;
|
|
123
|
+
stripNewlines?: boolean;
|
|
124
|
+
wrap?: boolean;
|
|
125
|
+
wrapWidth?: number;
|
|
126
|
+
convertAsInline?: boolean;
|
|
127
|
+
subSymbol?: string;
|
|
128
|
+
supSymbol?: string;
|
|
129
|
+
newlineStyle?: WasmNewlineStyle;
|
|
130
|
+
codeBlockStyle?: WasmCodeBlockStyle;
|
|
131
|
+
keepInlineImagesIn?: string[];
|
|
132
|
+
preprocessing?: WasmPreprocessingOptions | null;
|
|
133
|
+
encoding?: string;
|
|
134
|
+
debug?: boolean;
|
|
135
|
+
stripTags?: string[];
|
|
136
|
+
preserveTags?: string[];
|
|
137
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
let wasm;
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {import("./html_to_markdown_wasm").WasmConversionOptions} WasmConversionOptions
|
|
4
|
+
*/
|
|
5
|
+
|
|
2
6
|
export function __wbg_set_wasm(val) {
|
|
3
7
|
wasm = val;
|
|
4
8
|
}
|
|
@@ -268,7 +272,7 @@ export class WasmConversionOptionsHandle {
|
|
|
268
272
|
wasm.__wbg_wasmconversionoptionshandle_free(ptr, 0);
|
|
269
273
|
}
|
|
270
274
|
/**
|
|
271
|
-
* @param {
|
|
275
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
272
276
|
*/
|
|
273
277
|
constructor(options) {
|
|
274
278
|
try {
|
|
@@ -387,7 +391,7 @@ export class WasmInlineImage {
|
|
|
387
391
|
wasm.__wbg_wasminlineimage_free(ptr, 0);
|
|
388
392
|
}
|
|
389
393
|
/**
|
|
390
|
-
* @returns {
|
|
394
|
+
* @returns {Record<string, string>}
|
|
391
395
|
*/
|
|
392
396
|
get attributes() {
|
|
393
397
|
const ret = wasm.wasminlineimage_attributes(this.__wbg_ptr);
|
|
@@ -612,7 +616,7 @@ if (Symbol.dispose) WasmInlineImageWarning.prototype[Symbol.dispose] = WasmInlin
|
|
|
612
616
|
* console.log(markdown); // # Hello World
|
|
613
617
|
* ```
|
|
614
618
|
* @param {string} html
|
|
615
|
-
* @param {
|
|
619
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
616
620
|
* @returns {string}
|
|
617
621
|
*/
|
|
618
622
|
export function convert(html, options) {
|
|
@@ -644,7 +648,7 @@ export function convert(html, options) {
|
|
|
644
648
|
|
|
645
649
|
/**
|
|
646
650
|
* @param {Uint8Array} html
|
|
647
|
-
* @param {
|
|
651
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
648
652
|
* @returns {string}
|
|
649
653
|
*/
|
|
650
654
|
export function convertBytes(html, options) {
|
|
@@ -674,7 +678,7 @@ export function convertBytes(html, options) {
|
|
|
674
678
|
|
|
675
679
|
/**
|
|
676
680
|
* @param {Uint8Array} html
|
|
677
|
-
* @param {
|
|
681
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
678
682
|
* @param {WasmInlineImageConfig | null} [image_config]
|
|
679
683
|
* @returns {WasmHtmlExtraction}
|
|
680
684
|
*/
|
|
@@ -732,7 +736,7 @@ export function convertBytesWithOptionsHandle(html, handle) {
|
|
|
732
736
|
|
|
733
737
|
/**
|
|
734
738
|
* @param {string} html
|
|
735
|
-
* @param {
|
|
739
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
736
740
|
* @param {WasmInlineImageConfig | null} [image_config]
|
|
737
741
|
* @returns {WasmHtmlExtraction}
|
|
738
742
|
*/
|
|
@@ -793,7 +797,7 @@ export function convertWithOptionsHandle(html, handle) {
|
|
|
793
797
|
}
|
|
794
798
|
|
|
795
799
|
/**
|
|
796
|
-
* @param {
|
|
800
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
797
801
|
* @returns {WasmConversionOptionsHandle}
|
|
798
802
|
*/
|
|
799
803
|
export function createConversionOptionsHandle(options) {
|
|
Binary file
|
package/dist/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export class WasmConversionOptionsHandle {
|
|
5
5
|
free(): void;
|
|
6
6
|
[Symbol.dispose](): void;
|
|
7
|
-
constructor(options
|
|
7
|
+
constructor(options?: WasmConversionOptions | null);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export class WasmHtmlExtraction {
|
|
@@ -20,7 +20,7 @@ export class WasmInlineImage {
|
|
|
20
20
|
private constructor();
|
|
21
21
|
free(): void;
|
|
22
22
|
[Symbol.dispose](): void;
|
|
23
|
-
readonly attributes:
|
|
23
|
+
readonly attributes: Record<string, string>;
|
|
24
24
|
readonly dimensions: Uint32Array | undefined;
|
|
25
25
|
readonly description: string | undefined;
|
|
26
26
|
readonly data: Uint8Array;
|
|
@@ -64,21 +64,71 @@ export class WasmInlineImageWarning {
|
|
|
64
64
|
* console.log(markdown); // # Hello World
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
|
-
export function convert(html: string, options
|
|
67
|
+
export function convert(html: string, options?: WasmConversionOptions | null): string;
|
|
68
68
|
|
|
69
|
-
export function convertBytes(html: Uint8Array, options
|
|
69
|
+
export function convertBytes(html: Uint8Array, options?: WasmConversionOptions | null): string;
|
|
70
70
|
|
|
71
|
-
export function convertBytesWithInlineImages(html: Uint8Array, options
|
|
71
|
+
export function convertBytesWithInlineImages(html: Uint8Array, options?: WasmConversionOptions | null, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
|
|
72
72
|
|
|
73
73
|
export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
|
|
74
74
|
|
|
75
|
-
export function convertWithInlineImages(html: string, options
|
|
75
|
+
export function convertWithInlineImages(html: string, options?: WasmConversionOptions | null, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
|
|
76
76
|
|
|
77
77
|
export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
|
|
78
78
|
|
|
79
|
-
export function createConversionOptionsHandle(options
|
|
79
|
+
export function createConversionOptionsHandle(options?: WasmConversionOptions | null): WasmConversionOptionsHandle;
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* Initialize panic hook for better error messages in the browser
|
|
83
83
|
*/
|
|
84
84
|
export function init(): void;
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
export type WasmHeadingStyle = "underlined" | "atx" | "atxClosed";
|
|
88
|
+
export type WasmListIndentType = "spaces" | "tabs";
|
|
89
|
+
export type WasmWhitespaceMode = "normalized" | "strict";
|
|
90
|
+
export type WasmNewlineStyle = "spaces" | "backslash";
|
|
91
|
+
export type WasmCodeBlockStyle = "indented" | "backticks" | "tildes";
|
|
92
|
+
export type WasmHighlightStyle = "doubleEqual" | "html" | "bold" | "none";
|
|
93
|
+
export type WasmPreprocessingPreset = "minimal" | "standard" | "aggressive";
|
|
94
|
+
|
|
95
|
+
export interface WasmPreprocessingOptions {
|
|
96
|
+
enabled?: boolean;
|
|
97
|
+
preset?: WasmPreprocessingPreset;
|
|
98
|
+
removeNavigation?: boolean;
|
|
99
|
+
removeForms?: boolean;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface WasmConversionOptions {
|
|
103
|
+
headingStyle?: WasmHeadingStyle;
|
|
104
|
+
listIndentType?: WasmListIndentType;
|
|
105
|
+
listIndentWidth?: number;
|
|
106
|
+
bullets?: string;
|
|
107
|
+
strongEmSymbol?: string;
|
|
108
|
+
escapeAsterisks?: boolean;
|
|
109
|
+
escapeUnderscores?: boolean;
|
|
110
|
+
escapeMisc?: boolean;
|
|
111
|
+
escapeAscii?: boolean;
|
|
112
|
+
codeLanguage?: string;
|
|
113
|
+
autolinks?: boolean;
|
|
114
|
+
defaultTitle?: boolean;
|
|
115
|
+
brInTables?: boolean;
|
|
116
|
+
hocrSpatialTables?: boolean;
|
|
117
|
+
highlightStyle?: WasmHighlightStyle;
|
|
118
|
+
extractMetadata?: boolean;
|
|
119
|
+
whitespaceMode?: WasmWhitespaceMode;
|
|
120
|
+
stripNewlines?: boolean;
|
|
121
|
+
wrap?: boolean;
|
|
122
|
+
wrapWidth?: number;
|
|
123
|
+
convertAsInline?: boolean;
|
|
124
|
+
subSymbol?: string;
|
|
125
|
+
supSymbol?: string;
|
|
126
|
+
newlineStyle?: WasmNewlineStyle;
|
|
127
|
+
codeBlockStyle?: WasmCodeBlockStyle;
|
|
128
|
+
keepInlineImagesIn?: string[];
|
|
129
|
+
preprocessing?: WasmPreprocessingOptions | null;
|
|
130
|
+
encoding?: string;
|
|
131
|
+
debug?: boolean;
|
|
132
|
+
stripTags?: string[];
|
|
133
|
+
preserveTags?: string[];
|
|
134
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {import("./html_to_markdown_wasm").WasmConversionOptions} WasmConversionOptions
|
|
4
|
+
*/
|
|
5
|
+
|
|
2
6
|
let imports = {};
|
|
3
7
|
imports['__wbindgen_placeholder__'] = module.exports;
|
|
4
8
|
|
|
@@ -259,7 +263,7 @@ class WasmConversionOptionsHandle {
|
|
|
259
263
|
wasm.__wbg_wasmconversionoptionshandle_free(ptr, 0);
|
|
260
264
|
}
|
|
261
265
|
/**
|
|
262
|
-
* @param {
|
|
266
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
263
267
|
*/
|
|
264
268
|
constructor(options) {
|
|
265
269
|
try {
|
|
@@ -380,7 +384,7 @@ class WasmInlineImage {
|
|
|
380
384
|
wasm.__wbg_wasminlineimage_free(ptr, 0);
|
|
381
385
|
}
|
|
382
386
|
/**
|
|
383
|
-
* @returns {
|
|
387
|
+
* @returns {Record<string, string>}
|
|
384
388
|
*/
|
|
385
389
|
get attributes() {
|
|
386
390
|
const ret = wasm.wasminlineimage_attributes(this.__wbg_ptr);
|
|
@@ -608,7 +612,7 @@ exports.WasmInlineImageWarning = WasmInlineImageWarning;
|
|
|
608
612
|
* console.log(markdown); // # Hello World
|
|
609
613
|
* ```
|
|
610
614
|
* @param {string} html
|
|
611
|
-
* @param {
|
|
615
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
612
616
|
* @returns {string}
|
|
613
617
|
*/
|
|
614
618
|
function convert(html, options) {
|
|
@@ -641,7 +645,7 @@ exports.convert = convert;
|
|
|
641
645
|
|
|
642
646
|
/**
|
|
643
647
|
* @param {Uint8Array} html
|
|
644
|
-
* @param {
|
|
648
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
645
649
|
* @returns {string}
|
|
646
650
|
*/
|
|
647
651
|
function convertBytes(html, options) {
|
|
@@ -672,7 +676,7 @@ exports.convertBytes = convertBytes;
|
|
|
672
676
|
|
|
673
677
|
/**
|
|
674
678
|
* @param {Uint8Array} html
|
|
675
|
-
* @param {
|
|
679
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
676
680
|
* @param {WasmInlineImageConfig | null} [image_config]
|
|
677
681
|
* @returns {WasmHtmlExtraction}
|
|
678
682
|
*/
|
|
@@ -732,7 +736,7 @@ exports.convertBytesWithOptionsHandle = convertBytesWithOptionsHandle;
|
|
|
732
736
|
|
|
733
737
|
/**
|
|
734
738
|
* @param {string} html
|
|
735
|
-
* @param {
|
|
739
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
736
740
|
* @param {WasmInlineImageConfig | null} [image_config]
|
|
737
741
|
* @returns {WasmHtmlExtraction}
|
|
738
742
|
*/
|
|
@@ -795,7 +799,7 @@ function convertWithOptionsHandle(html, handle) {
|
|
|
795
799
|
exports.convertWithOptionsHandle = convertWithOptionsHandle;
|
|
796
800
|
|
|
797
801
|
/**
|
|
798
|
-
* @param {
|
|
802
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
799
803
|
* @returns {WasmConversionOptionsHandle}
|
|
800
804
|
*/
|
|
801
805
|
function createConversionOptionsHandle(options) {
|
|
Binary file
|
package/dist-node/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export class WasmConversionOptionsHandle {
|
|
5
5
|
free(): void;
|
|
6
6
|
[Symbol.dispose](): void;
|
|
7
|
-
constructor(options
|
|
7
|
+
constructor(options?: WasmConversionOptions | null);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export class WasmHtmlExtraction {
|
|
@@ -20,7 +20,7 @@ export class WasmInlineImage {
|
|
|
20
20
|
private constructor();
|
|
21
21
|
free(): void;
|
|
22
22
|
[Symbol.dispose](): void;
|
|
23
|
-
readonly attributes:
|
|
23
|
+
readonly attributes: Record<string, string>;
|
|
24
24
|
readonly dimensions: Uint32Array | undefined;
|
|
25
25
|
readonly description: string | undefined;
|
|
26
26
|
readonly data: Uint8Array;
|
|
@@ -64,19 +64,19 @@ export class WasmInlineImageWarning {
|
|
|
64
64
|
* console.log(markdown); // # Hello World
|
|
65
65
|
* ```
|
|
66
66
|
*/
|
|
67
|
-
export function convert(html: string, options
|
|
67
|
+
export function convert(html: string, options?: WasmConversionOptions | null): string;
|
|
68
68
|
|
|
69
|
-
export function convertBytes(html: Uint8Array, options
|
|
69
|
+
export function convertBytes(html: Uint8Array, options?: WasmConversionOptions | null): string;
|
|
70
70
|
|
|
71
|
-
export function convertBytesWithInlineImages(html: Uint8Array, options
|
|
71
|
+
export function convertBytesWithInlineImages(html: Uint8Array, options?: WasmConversionOptions | null, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
|
|
72
72
|
|
|
73
73
|
export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
|
|
74
74
|
|
|
75
|
-
export function convertWithInlineImages(html: string, options
|
|
75
|
+
export function convertWithInlineImages(html: string, options?: WasmConversionOptions | null, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
|
|
76
76
|
|
|
77
77
|
export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
|
|
78
78
|
|
|
79
|
-
export function createConversionOptionsHandle(options
|
|
79
|
+
export function createConversionOptionsHandle(options?: WasmConversionOptions | null): WasmConversionOptionsHandle;
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* Initialize panic hook for better error messages in the browser
|
|
@@ -146,3 +146,53 @@ export function initSync(module: { module: SyncInitInput } | SyncInitInput): Ini
|
|
|
146
146
|
* @returns {Promise<InitOutput>}
|
|
147
147
|
*/
|
|
148
148
|
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
export type WasmHeadingStyle = "underlined" | "atx" | "atxClosed";
|
|
152
|
+
export type WasmListIndentType = "spaces" | "tabs";
|
|
153
|
+
export type WasmWhitespaceMode = "normalized" | "strict";
|
|
154
|
+
export type WasmNewlineStyle = "spaces" | "backslash";
|
|
155
|
+
export type WasmCodeBlockStyle = "indented" | "backticks" | "tildes";
|
|
156
|
+
export type WasmHighlightStyle = "doubleEqual" | "html" | "bold" | "none";
|
|
157
|
+
export type WasmPreprocessingPreset = "minimal" | "standard" | "aggressive";
|
|
158
|
+
|
|
159
|
+
export interface WasmPreprocessingOptions {
|
|
160
|
+
enabled?: boolean;
|
|
161
|
+
preset?: WasmPreprocessingPreset;
|
|
162
|
+
removeNavigation?: boolean;
|
|
163
|
+
removeForms?: boolean;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface WasmConversionOptions {
|
|
167
|
+
headingStyle?: WasmHeadingStyle;
|
|
168
|
+
listIndentType?: WasmListIndentType;
|
|
169
|
+
listIndentWidth?: number;
|
|
170
|
+
bullets?: string;
|
|
171
|
+
strongEmSymbol?: string;
|
|
172
|
+
escapeAsterisks?: boolean;
|
|
173
|
+
escapeUnderscores?: boolean;
|
|
174
|
+
escapeMisc?: boolean;
|
|
175
|
+
escapeAscii?: boolean;
|
|
176
|
+
codeLanguage?: string;
|
|
177
|
+
autolinks?: boolean;
|
|
178
|
+
defaultTitle?: boolean;
|
|
179
|
+
brInTables?: boolean;
|
|
180
|
+
hocrSpatialTables?: boolean;
|
|
181
|
+
highlightStyle?: WasmHighlightStyle;
|
|
182
|
+
extractMetadata?: boolean;
|
|
183
|
+
whitespaceMode?: WasmWhitespaceMode;
|
|
184
|
+
stripNewlines?: boolean;
|
|
185
|
+
wrap?: boolean;
|
|
186
|
+
wrapWidth?: number;
|
|
187
|
+
convertAsInline?: boolean;
|
|
188
|
+
subSymbol?: string;
|
|
189
|
+
supSymbol?: string;
|
|
190
|
+
newlineStyle?: WasmNewlineStyle;
|
|
191
|
+
codeBlockStyle?: WasmCodeBlockStyle;
|
|
192
|
+
keepInlineImagesIn?: string[];
|
|
193
|
+
preprocessing?: WasmPreprocessingOptions | null;
|
|
194
|
+
encoding?: string;
|
|
195
|
+
debug?: boolean;
|
|
196
|
+
stripTags?: string[];
|
|
197
|
+
preserveTags?: string[];
|
|
198
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
let wasm;
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {import("./html_to_markdown_wasm").WasmConversionOptions} WasmConversionOptions
|
|
4
|
+
*/
|
|
5
|
+
|
|
2
6
|
|
|
3
7
|
function addHeapObject(obj) {
|
|
4
8
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
@@ -265,7 +269,7 @@ export class WasmConversionOptionsHandle {
|
|
|
265
269
|
wasm.__wbg_wasmconversionoptionshandle_free(ptr, 0);
|
|
266
270
|
}
|
|
267
271
|
/**
|
|
268
|
-
* @param {
|
|
272
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
269
273
|
*/
|
|
270
274
|
constructor(options) {
|
|
271
275
|
try {
|
|
@@ -384,7 +388,7 @@ export class WasmInlineImage {
|
|
|
384
388
|
wasm.__wbg_wasminlineimage_free(ptr, 0);
|
|
385
389
|
}
|
|
386
390
|
/**
|
|
387
|
-
* @returns {
|
|
391
|
+
* @returns {Record<string, string>}
|
|
388
392
|
*/
|
|
389
393
|
get attributes() {
|
|
390
394
|
const ret = wasm.wasminlineimage_attributes(this.__wbg_ptr);
|
|
@@ -609,7 +613,7 @@ if (Symbol.dispose) WasmInlineImageWarning.prototype[Symbol.dispose] = WasmInlin
|
|
|
609
613
|
* console.log(markdown); // # Hello World
|
|
610
614
|
* ```
|
|
611
615
|
* @param {string} html
|
|
612
|
-
* @param {
|
|
616
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
613
617
|
* @returns {string}
|
|
614
618
|
*/
|
|
615
619
|
export function convert(html, options) {
|
|
@@ -641,7 +645,7 @@ export function convert(html, options) {
|
|
|
641
645
|
|
|
642
646
|
/**
|
|
643
647
|
* @param {Uint8Array} html
|
|
644
|
-
* @param {
|
|
648
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
645
649
|
* @returns {string}
|
|
646
650
|
*/
|
|
647
651
|
export function convertBytes(html, options) {
|
|
@@ -671,7 +675,7 @@ export function convertBytes(html, options) {
|
|
|
671
675
|
|
|
672
676
|
/**
|
|
673
677
|
* @param {Uint8Array} html
|
|
674
|
-
* @param {
|
|
678
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
675
679
|
* @param {WasmInlineImageConfig | null} [image_config]
|
|
676
680
|
* @returns {WasmHtmlExtraction}
|
|
677
681
|
*/
|
|
@@ -729,7 +733,7 @@ export function convertBytesWithOptionsHandle(html, handle) {
|
|
|
729
733
|
|
|
730
734
|
/**
|
|
731
735
|
* @param {string} html
|
|
732
|
-
* @param {
|
|
736
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
733
737
|
* @param {WasmInlineImageConfig | null} [image_config]
|
|
734
738
|
* @returns {WasmHtmlExtraction}
|
|
735
739
|
*/
|
|
@@ -790,7 +794,7 @@ export function convertWithOptionsHandle(html, handle) {
|
|
|
790
794
|
}
|
|
791
795
|
|
|
792
796
|
/**
|
|
793
|
-
* @param {
|
|
797
|
+
* @param {WasmConversionOptions | null | undefined} [options]
|
|
794
798
|
* @returns {WasmConversionOptionsHandle}
|
|
795
799
|
*/
|
|
796
800
|
export function createConversionOptionsHandle(options) {
|
|
Binary file
|
package/dist-web/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
2
|
+
"name": "html-to-markdown-wasm",
|
|
3
|
+
"version": "2.11.4",
|
|
4
|
+
"description": "High-performance HTML to Markdown converter - WebAssembly bindings",
|
|
5
|
+
"main": "dist/html_to_markdown_wasm.js",
|
|
6
|
+
"types": "dist/html_to_markdown_wasm.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/html_to_markdown_wasm.js",
|
|
10
|
+
"types": "./dist/html_to_markdown_wasm.d.ts",
|
|
11
|
+
"default": "./dist/html_to_markdown_wasm.js"
|
|
12
|
+
},
|
|
13
|
+
"./dist-node": {
|
|
14
|
+
"import": "./dist-node/html_to_markdown_wasm.js",
|
|
15
|
+
"require": "./dist-node/html_to_markdown_wasm.js",
|
|
16
|
+
"types": "./dist-node/html_to_markdown_wasm.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./dist-node/*": "./dist-node/*",
|
|
19
|
+
"./dist-web": {
|
|
20
|
+
"import": "./dist-web/html_to_markdown_wasm.js",
|
|
21
|
+
"types": "./dist-web/html_to_markdown_wasm.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./dist-web/*": "./dist-web/*"
|
|
24
|
+
},
|
|
25
|
+
"repository": "https://github.com/Goldziher/html-to-markdown",
|
|
26
|
+
"homepage": "https://github.com/Goldziher/html-to-markdown",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"author": "Na'aman Hirschfeld <nhirschfeld@gmail.com>",
|
|
29
|
+
"bugs": "https://github.com/Goldziher/html-to-markdown/issues",
|
|
30
|
+
"keywords": [
|
|
31
|
+
"html",
|
|
32
|
+
"markdown",
|
|
33
|
+
"converter",
|
|
34
|
+
"rust",
|
|
35
|
+
"wasm",
|
|
36
|
+
"webassembly"
|
|
37
|
+
],
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"dist-node",
|
|
41
|
+
"dist-web",
|
|
42
|
+
"README.md"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "wasm-pack build --target bundler --out-dir dist && node ./scripts/patch-bundler-entry.js",
|
|
46
|
+
"build:nodejs": "wasm-pack build --target nodejs --out-dir dist-node && node ./scripts/patch-bundler-entry.js dist-node --types-only",
|
|
47
|
+
"build:web": "wasm-pack build --target web --out-dir dist-web && node ./scripts/patch-bundler-entry.js dist-web --types-only",
|
|
48
|
+
"build:all": "pnpm run build && pnpm run build:nodejs && pnpm run build:web && pnpm run cleanup:gitignore",
|
|
49
|
+
"cleanup:gitignore": "node ./scripts/cleanup-gitignore.js",
|
|
50
|
+
"test": "vitest run",
|
|
51
|
+
"test:watch": "vitest",
|
|
52
|
+
"test:wasm-pack": "wasm-pack test --headless --chrome",
|
|
53
|
+
"clean": "rm -rf dist dist-node dist-web node_modules pkg"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^24.10.1",
|
|
57
|
+
"tsx": "^4.21.0",
|
|
58
|
+
"vitest": "^4.0.15",
|
|
59
|
+
"wasm-pack": "^0.13.1"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"registry": "https://registry.npmjs.org/",
|
|
63
|
+
"access": "public"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"up": "^1.0.2"
|
|
67
|
+
}
|
|
68
68
|
}
|