md4x 0.0.21 → 0.0.22
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/build/md4x.darwin-arm64.node +0 -0
- package/build/md4x.darwin-x64.node +0 -0
- package/build/md4x.linux-arm.node +0 -0
- package/build/md4x.linux-arm64-musl.node +0 -0
- package/build/md4x.linux-arm64.node +0 -0
- package/build/md4x.linux-x64-musl.node +0 -0
- package/build/md4x.linux-x64.node +0 -0
- package/build/md4x.wasm +0 -0
- package/build/md4x.win32-arm64.node +0 -0
- package/build/md4x.win32-x64.node +0 -0
- package/lib/cli.mjs +14 -2
- package/lib/napi.d.mts +5 -0
- package/lib/napi.mjs +5 -0
- package/lib/wasm/common.mjs +6 -0
- package/lib/wasm/default.mjs +1 -0
- package/lib/wasm/index.d.mts +4 -0
- package/lib/wasm/unwasm.mjs +1 -0
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/build/md4x.wasm
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/cli.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
renderToHtml,
|
|
7
7
|
renderToAnsi,
|
|
8
8
|
renderToText,
|
|
9
|
+
renderToMarkdown,
|
|
9
10
|
parseAST,
|
|
10
11
|
parseMeta,
|
|
11
12
|
heal,
|
|
@@ -47,7 +48,7 @@ ${_g("Usage:")} ${_b("md4x")} ${_d("[OPTION]... [FILE]")}
|
|
|
47
48
|
|
|
48
49
|
${_g("General options:")}
|
|
49
50
|
${_c("-o")}, ${_c("--output")}=${_d("FILE")} Output file ${_d("(default: stdout)")}
|
|
50
|
-
${_c("-t")}, ${_c("--format")}=${_d("FORMAT")} Output format: ${_c("html")}, ${_c("text")}, ${_c("ast")}, ${_c("ansi")}, ${_c("meta")}, ${_c("heal")} ${_d("(default: ansi for TTY, text otherwise)")}
|
|
51
|
+
${_c("-t")}, ${_c("--format")}=${_d("FORMAT")} Output format: ${_c("html")}, ${_c("text")}, ${_c("ast")}, ${_c("ansi")}, ${_c("meta")}, ${_c("markdown")}, ${_c("heal")} ${_d("(default: ansi for TTY, text otherwise)")}
|
|
51
52
|
${_c("--heal")} Heal incomplete markdown before rendering
|
|
52
53
|
${_c("--show-urls")} Show link URLs after link text ${_d("(ANSI only)")}
|
|
53
54
|
${_c("--show-frontmatter")} Show frontmatter content ${_d("(ANSI only)")}
|
|
@@ -96,7 +97,15 @@ if (values.version) {
|
|
|
96
97
|
process.exit(0);
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
const supportedFormats = [
|
|
100
|
+
const supportedFormats = [
|
|
101
|
+
"html",
|
|
102
|
+
"ast",
|
|
103
|
+
"ansi",
|
|
104
|
+
"text",
|
|
105
|
+
"meta",
|
|
106
|
+
"markdown",
|
|
107
|
+
"heal",
|
|
108
|
+
];
|
|
100
109
|
const format = values.format;
|
|
101
110
|
if (!supportedFormats.includes(format)) {
|
|
102
111
|
process.stderr.write(`Unknown format: ${format}\n`);
|
|
@@ -184,6 +193,9 @@ switch (format) {
|
|
|
184
193
|
case "meta":
|
|
185
194
|
output = JSON.stringify(parseMeta(input, healOpt), null, 2);
|
|
186
195
|
break;
|
|
196
|
+
case "markdown":
|
|
197
|
+
output = renderToMarkdown(input, healOpt);
|
|
198
|
+
break;
|
|
187
199
|
case "heal":
|
|
188
200
|
output = heal(input);
|
|
189
201
|
break;
|
package/lib/napi.d.mts
CHANGED
|
@@ -29,6 +29,7 @@ export interface NAPIBinding {
|
|
|
29
29
|
renderToAnsiMeta(input: string): Buffer;
|
|
30
30
|
renderToMeta(input: string, flags?: number): string;
|
|
31
31
|
renderToText(input: string, flags?: number): string;
|
|
32
|
+
renderToMarkdown(input: string, flags?: number): string;
|
|
32
33
|
heal(input: string): string;
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -59,4 +60,8 @@ export declare function renderToText(
|
|
|
59
60
|
input: string,
|
|
60
61
|
opts?: RenderOptions,
|
|
61
62
|
): string;
|
|
63
|
+
export declare function renderToMarkdown(
|
|
64
|
+
input: string,
|
|
65
|
+
opts?: RenderOptions,
|
|
66
|
+
): string;
|
|
62
67
|
export declare function heal(input: string): string;
|
package/lib/napi.mjs
CHANGED
|
@@ -89,6 +89,11 @@ export function renderToText(input, opts) {
|
|
|
89
89
|
return getBinding().renderToText(str(input), flags);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
export function renderToMarkdown(input, opts) {
|
|
93
|
+
const flags = opts?.heal ? HEAL_FLAG : 0;
|
|
94
|
+
return getBinding().renderToMarkdown(str(input), flags);
|
|
95
|
+
}
|
|
96
|
+
|
|
92
97
|
export function parseMeta(input, opts) {
|
|
93
98
|
const meta = JSON.parse(renderToMeta(input, opts));
|
|
94
99
|
if (!meta.title && meta.headings?.[0]) {
|
package/lib/wasm/common.mjs
CHANGED
|
@@ -138,6 +138,12 @@ export function renderToText(input, opts) {
|
|
|
138
138
|
return render(exports, exports.md4x_to_text, input, flags);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
export function renderToMarkdown(input, opts) {
|
|
142
|
+
const flags = opts?.heal ? HEAL_FLAG : 0;
|
|
143
|
+
const exports = _getExports();
|
|
144
|
+
return render(exports, exports.md4x_to_markdown, input, flags);
|
|
145
|
+
}
|
|
146
|
+
|
|
141
147
|
export function parseMeta(input, opts) {
|
|
142
148
|
const meta = JSON.parse(renderToMeta(input, opts));
|
|
143
149
|
if (!meta.title && meta.headings?.[0]) {
|
package/lib/wasm/default.mjs
CHANGED
package/lib/wasm/index.d.mts
CHANGED
package/lib/wasm/unwasm.mjs
CHANGED