ironmark 1.11.4 → 1.12.1
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 +137 -24
- package/package.json +1 -1
- package/wasm/index.d.ts +66 -0
- package/wasm/node.js +12 -2
- package/wasm/pkg/ironmark.d.ts +35 -0
- package/wasm/pkg/ironmark.js +1 -1
- package/wasm/pkg/ironmark_bg.js +110 -0
- package/wasm/pkg/ironmark_bg.wasm +0 -0
- package/wasm/pkg/ironmark_bg.wasm.d.ts +3 -0
- package/wasm/shared.js +18 -0
- package/wasm/web.js +11 -1
package/wasm/pkg/ironmark.d.ts
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Convert HTML to Markdown.
|
|
6
|
+
*
|
|
7
|
+
* This parses HTML and renders it as Markdown syntax.
|
|
8
|
+
*
|
|
9
|
+
* @param html - HTML source string.
|
|
10
|
+
* @param preserveUnknownAsHtml - If true, unknown HTML tags are preserved as raw HTML in output.
|
|
11
|
+
* If false (default), unknown tags are stripped but text is kept.
|
|
12
|
+
* @returns Markdown string.
|
|
13
|
+
*/
|
|
14
|
+
export function htmlToMarkdown(html: string, preserve_unknown_as_html?: boolean | null): string;
|
|
15
|
+
|
|
4
16
|
export function parse(markdown: string, hard_breaks?: boolean | null, enable_highlight?: boolean | null, enable_strikethrough?: boolean | null, enable_underline?: boolean | null, enable_tables?: boolean | null, enable_autolink?: boolean | null, enable_task_lists?: boolean | null, disable_raw_html?: boolean | null, enable_heading_ids?: boolean | null, enable_heading_anchors?: boolean | null, enable_indented_code_blocks?: boolean | null, no_html_blocks?: boolean | null, no_html_spans?: boolean | null, tag_filter?: boolean | null, collapse_whitespace?: boolean | null, permissive_atx_headers?: boolean | null, enable_wiki_links?: boolean | null, enable_latex_math?: boolean | null): string;
|
|
5
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Parse an HTML string and return the AST as JSON.
|
|
20
|
+
*
|
|
21
|
+
* This converts HTML back into the same AST structure used by the Markdown parser,
|
|
22
|
+
* enabling HTML-to-Markdown conversion.
|
|
23
|
+
*
|
|
24
|
+
* @param html - HTML source string.
|
|
25
|
+
* @param preserveUnknownAsHtml - If true, unknown HTML tags are preserved as raw HTML.
|
|
26
|
+
* If false (default), unknown tags are stripped but text is kept.
|
|
27
|
+
* @returns JSON string representing the AST.
|
|
28
|
+
*/
|
|
29
|
+
export function parseHtmlToAst(html: string, preserve_unknown_as_html?: boolean | null): string;
|
|
30
|
+
|
|
6
31
|
export function parseToAst(markdown: string, hard_breaks?: boolean | null, enable_highlight?: boolean | null, enable_strikethrough?: boolean | null, enable_underline?: boolean | null, enable_tables?: boolean | null, enable_autolink?: boolean | null, enable_task_lists?: boolean | null, disable_raw_html?: boolean | null, enable_heading_ids?: boolean | null, enable_heading_anchors?: boolean | null, enable_indented_code_blocks?: boolean | null, no_html_blocks?: boolean | null, no_html_spans?: boolean | null, tag_filter?: boolean | null, collapse_whitespace?: boolean | null, permissive_atx_headers?: boolean | null, enable_wiki_links?: boolean | null, enable_latex_math?: boolean | null): string;
|
|
7
32
|
|
|
8
33
|
/**
|
|
@@ -19,3 +44,13 @@ export function parseToAst(markdown: string, hard_breaks?: boolean | null, enabl
|
|
|
19
44
|
* @param lineNumbers - Show line numbers in fenced code blocks (default: false).
|
|
20
45
|
*/
|
|
21
46
|
export function renderAnsi(markdown: string, hard_breaks: boolean | null | undefined, enable_highlight: boolean | null | undefined, enable_strikethrough: boolean | null | undefined, enable_underline: boolean | null | undefined, enable_tables: boolean | null | undefined, enable_autolink: boolean | null | undefined, enable_task_lists: boolean | null | undefined, disable_raw_html: boolean | null | undefined, enable_heading_ids: boolean | null | undefined, enable_heading_anchors: boolean | null | undefined, enable_indented_code_blocks: boolean | null | undefined, no_html_blocks: boolean | null | undefined, no_html_spans: boolean | null | undefined, tag_filter: boolean | null | undefined, collapse_whitespace: boolean | null | undefined, permissive_atx_headers: boolean | null | undefined, enable_wiki_links: boolean | null | undefined, enable_latex_math: boolean | null | undefined, width: number, color: boolean | null | undefined, line_numbers: boolean | null | undefined, padding: number): string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Render an AST (as JSON) to Markdown.
|
|
50
|
+
*
|
|
51
|
+
* This takes a JSON string representing an ironmark AST and renders it as Markdown.
|
|
52
|
+
*
|
|
53
|
+
* @param astJson - JSON string representing the AST (as returned by `parseToAst` or `parseHtmlToAst`).
|
|
54
|
+
* @returns Markdown string.
|
|
55
|
+
*/
|
|
56
|
+
export function renderMarkdown(ast_json: string): string;
|
package/wasm/pkg/ironmark.js
CHANGED
package/wasm/pkg/ironmark_bg.js
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert HTML to Markdown.
|
|
3
|
+
*
|
|
4
|
+
* This parses HTML and renders it as Markdown syntax.
|
|
5
|
+
*
|
|
6
|
+
* @param html - HTML source string.
|
|
7
|
+
* @param preserveUnknownAsHtml - If true, unknown HTML tags are preserved as raw HTML in output.
|
|
8
|
+
* If false (default), unknown tags are stripped but text is kept.
|
|
9
|
+
* @returns Markdown string.
|
|
10
|
+
* @param {string} html
|
|
11
|
+
* @param {boolean | null} [preserve_unknown_as_html]
|
|
12
|
+
* @returns {string}
|
|
13
|
+
*/
|
|
14
|
+
export function htmlToMarkdown(html, preserve_unknown_as_html) {
|
|
15
|
+
let deferred2_0;
|
|
16
|
+
let deferred2_1;
|
|
17
|
+
try {
|
|
18
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
19
|
+
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
20
|
+
const len0 = WASM_VECTOR_LEN;
|
|
21
|
+
wasm.htmlToMarkdown(retptr, ptr0, len0, isLikeNone(preserve_unknown_as_html) ? 0xFFFFFF : preserve_unknown_as_html ? 1 : 0);
|
|
22
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
23
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
24
|
+
deferred2_0 = r0;
|
|
25
|
+
deferred2_1 = r1;
|
|
26
|
+
return getStringFromWasm0(r0, r1);
|
|
27
|
+
} finally {
|
|
28
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
29
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
1
33
|
/**
|
|
2
34
|
* @param {string} markdown
|
|
3
35
|
* @param {boolean | null} [hard_breaks]
|
|
@@ -39,6 +71,47 @@ export function parse(markdown, hard_breaks, enable_highlight, enable_strikethro
|
|
|
39
71
|
}
|
|
40
72
|
}
|
|
41
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Parse an HTML string and return the AST as JSON.
|
|
76
|
+
*
|
|
77
|
+
* This converts HTML back into the same AST structure used by the Markdown parser,
|
|
78
|
+
* enabling HTML-to-Markdown conversion.
|
|
79
|
+
*
|
|
80
|
+
* @param html - HTML source string.
|
|
81
|
+
* @param preserveUnknownAsHtml - If true, unknown HTML tags are preserved as raw HTML.
|
|
82
|
+
* If false (default), unknown tags are stripped but text is kept.
|
|
83
|
+
* @returns JSON string representing the AST.
|
|
84
|
+
* @param {string} html
|
|
85
|
+
* @param {boolean | null} [preserve_unknown_as_html]
|
|
86
|
+
* @returns {string}
|
|
87
|
+
*/
|
|
88
|
+
export function parseHtmlToAst(html, preserve_unknown_as_html) {
|
|
89
|
+
let deferred3_0;
|
|
90
|
+
let deferred3_1;
|
|
91
|
+
try {
|
|
92
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
93
|
+
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
94
|
+
const len0 = WASM_VECTOR_LEN;
|
|
95
|
+
wasm.parseHtmlToAst(retptr, ptr0, len0, isLikeNone(preserve_unknown_as_html) ? 0xFFFFFF : preserve_unknown_as_html ? 1 : 0);
|
|
96
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
97
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
98
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
99
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
100
|
+
var ptr2 = r0;
|
|
101
|
+
var len2 = r1;
|
|
102
|
+
if (r3) {
|
|
103
|
+
ptr2 = 0; len2 = 0;
|
|
104
|
+
throw takeObject(r2);
|
|
105
|
+
}
|
|
106
|
+
deferred3_0 = ptr2;
|
|
107
|
+
deferred3_1 = len2;
|
|
108
|
+
return getStringFromWasm0(ptr2, len2);
|
|
109
|
+
} finally {
|
|
110
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
111
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
42
115
|
/**
|
|
43
116
|
* @param {string} markdown
|
|
44
117
|
* @param {boolean | null} [hard_breaks]
|
|
@@ -143,6 +216,43 @@ export function renderAnsi(markdown, hard_breaks, enable_highlight, enable_strik
|
|
|
143
216
|
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
144
217
|
}
|
|
145
218
|
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Render an AST (as JSON) to Markdown.
|
|
222
|
+
*
|
|
223
|
+
* This takes a JSON string representing an ironmark AST and renders it as Markdown.
|
|
224
|
+
*
|
|
225
|
+
* @param astJson - JSON string representing the AST (as returned by `parseToAst` or `parseHtmlToAst`).
|
|
226
|
+
* @returns Markdown string.
|
|
227
|
+
* @param {string} ast_json
|
|
228
|
+
* @returns {string}
|
|
229
|
+
*/
|
|
230
|
+
export function renderMarkdown(ast_json) {
|
|
231
|
+
let deferred3_0;
|
|
232
|
+
let deferred3_1;
|
|
233
|
+
try {
|
|
234
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
235
|
+
const ptr0 = passStringToWasm0(ast_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
236
|
+
const len0 = WASM_VECTOR_LEN;
|
|
237
|
+
wasm.renderMarkdown(retptr, ptr0, len0);
|
|
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
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
242
|
+
var ptr2 = r0;
|
|
243
|
+
var len2 = r1;
|
|
244
|
+
if (r3) {
|
|
245
|
+
ptr2 = 0; len2 = 0;
|
|
246
|
+
throw takeObject(r2);
|
|
247
|
+
}
|
|
248
|
+
deferred3_0 = ptr2;
|
|
249
|
+
deferred3_1 = len2;
|
|
250
|
+
return getStringFromWasm0(ptr2, len2);
|
|
251
|
+
} finally {
|
|
252
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
253
|
+
wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
146
256
|
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
147
257
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
148
258
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
Binary file
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const htmlToMarkdown: (a: number, b: number, c: number, d: number) => void;
|
|
4
5
|
export const parse: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number) => void;
|
|
6
|
+
export const parseHtmlToAst: (a: number, b: number, c: number, d: number) => void;
|
|
5
7
|
export const parseToAst: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number) => void;
|
|
6
8
|
export const renderAnsi: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number) => void;
|
|
9
|
+
export const renderMarkdown: (a: number, b: number, c: number) => void;
|
|
7
10
|
export const ironmark_free: (a: number) => void;
|
|
8
11
|
export const ironmark_parse: (a: number) => number;
|
|
9
12
|
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
package/wasm/shared.js
CHANGED
|
@@ -59,3 +59,21 @@ export function createRenderAnsi(wasmRenderAnsi) {
|
|
|
59
59
|
);
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
export function createParseHtmlToAst(wasmParseHtmlToAst) {
|
|
64
|
+
return function parseHtmlToAst(html, preserveUnknownAsHtml) {
|
|
65
|
+
return wasmParseHtmlToAst(html, preserveUnknownAsHtml);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function createHtmlToMarkdown(wasmHtmlToMarkdown) {
|
|
70
|
+
return function htmlToMarkdown(html, preserveUnknownAsHtml) {
|
|
71
|
+
return wasmHtmlToMarkdown(html, preserveUnknownAsHtml);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function createRenderMarkdown(wasmRenderMarkdown) {
|
|
76
|
+
return function renderMarkdown(astJson) {
|
|
77
|
+
return wasmRenderMarkdown(astJson);
|
|
78
|
+
};
|
|
79
|
+
}
|
package/wasm/web.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import * as wasmGlue from "./pkg/ironmark_bg.js";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createParse,
|
|
4
|
+
createParseToAst,
|
|
5
|
+
createRenderAnsi,
|
|
6
|
+
createParseHtmlToAst,
|
|
7
|
+
createHtmlToMarkdown,
|
|
8
|
+
createRenderMarkdown,
|
|
9
|
+
} from "./shared.js";
|
|
3
10
|
|
|
4
11
|
let initialized = false;
|
|
5
12
|
|
|
@@ -30,3 +37,6 @@ export async function init(input) {
|
|
|
30
37
|
export const parse = createParse(wasmGlue.parse);
|
|
31
38
|
export const parseToAst = createParseToAst(wasmGlue.parseToAst);
|
|
32
39
|
export const renderAnsi = createRenderAnsi(wasmGlue.renderAnsi);
|
|
40
|
+
export const parseHtmlToAst = createParseHtmlToAst(wasmGlue.parseHtmlToAst);
|
|
41
|
+
export const htmlToMarkdown = createHtmlToMarkdown(wasmGlue.htmlToMarkdown);
|
|
42
|
+
export const renderMarkdown = createRenderMarkdown(wasmGlue.renderMarkdown);
|