ironmark 1.12.2 → 1.13.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 +37 -28
- package/package.json +3 -3
- package/wasm/cli.js +54 -29
- package/wasm/node.js +1 -1
- package/wasm/pkg/ironmark_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -195,19 +195,19 @@ const html = parse("# Hello\n\nThis is **fast**.");
|
|
|
195
195
|
|
|
196
196
|
## CLI
|
|
197
197
|
|
|
198
|
-
Render Markdown as
|
|
198
|
+
Render Markdown as HTML, ANSI terminal output, or an AST. Default format is `html`.
|
|
199
199
|
|
|
200
200
|
### npm
|
|
201
201
|
|
|
202
202
|
```bash
|
|
203
|
-
npx ironmark
|
|
203
|
+
npx ironmark README.md
|
|
204
204
|
```
|
|
205
205
|
|
|
206
206
|
Or install globally:
|
|
207
207
|
|
|
208
208
|
```bash
|
|
209
209
|
npm install -g ironmark
|
|
210
|
-
ironmark
|
|
210
|
+
ironmark README.md
|
|
211
211
|
```
|
|
212
212
|
|
|
213
213
|
### Rust
|
|
@@ -216,47 +216,56 @@ Native binary — faster startup, auto-detects terminal width via `$COLUMNS` / `
|
|
|
216
216
|
|
|
217
217
|
```bash
|
|
218
218
|
cargo install ironmark --features cli
|
|
219
|
-
ironmark
|
|
219
|
+
ironmark README.md
|
|
220
220
|
```
|
|
221
221
|
|
|
222
222
|
### Options
|
|
223
223
|
|
|
224
|
-
Both CLIs support the same flags
|
|
224
|
+
Both CLIs support the same flags:
|
|
225
225
|
|
|
226
226
|
```text
|
|
227
|
-
OPTIONS:
|
|
227
|
+
OPTIONS (all formats):
|
|
228
|
+
--format <html|ansi|ast> Output format; ast also accepts 'json' (default: html)
|
|
229
|
+
--no-hard-breaks Don't turn soft newlines into hard line breaks
|
|
230
|
+
--no-tables Disable pipe table syntax
|
|
231
|
+
--no-highlight Disable ==highlight== syntax
|
|
232
|
+
--no-strikethrough Disable ~~strikethrough~~ syntax
|
|
233
|
+
--no-underline Disable ++underline++ syntax
|
|
234
|
+
--no-autolink Disable bare URL auto-linking
|
|
235
|
+
--no-task-lists Disable - [x] task list syntax
|
|
236
|
+
--math Enable $inline$ and $$display$$ math
|
|
237
|
+
--wiki-links Enable [[wiki link]] syntax
|
|
238
|
+
--max-size N Truncate input to N bytes (Rust only)
|
|
239
|
+
-h, --help Print this help and exit
|
|
240
|
+
-V, --version Print version and exit
|
|
241
|
+
|
|
242
|
+
OPTIONS (ansi format only):
|
|
228
243
|
--width N Terminal column width (default: auto-detect, fallback 80)
|
|
229
|
-
--padding N Horizontal padding added to both sides of each line
|
|
244
|
+
--padding N Horizontal padding added to both sides of each line (default: 0)
|
|
230
245
|
--no-color Disable ANSI escape codes (plain text)
|
|
231
246
|
-n, --line-numbers Show line numbers in fenced code blocks
|
|
232
|
-
--no-hard-breaks Don't turn soft newlines into hard line breaks
|
|
233
|
-
--no-tables Disable pipe table syntax
|
|
234
|
-
--no-highlight Disable ==highlight== syntax
|
|
235
|
-
--no-strikethrough Disable ~~strikethrough~~ syntax
|
|
236
|
-
--no-underline Disable ++underline++ syntax
|
|
237
|
-
--no-autolink Disable bare URL auto-linking
|
|
238
|
-
--no-task-lists Disable - [x] task list syntax
|
|
239
|
-
--math Enable $inline$ and $$display$$ math
|
|
240
|
-
--wiki-links Enable [[wiki link]] syntax
|
|
241
|
-
--max-size N Truncate input to N bytes (Rust only)
|
|
242
|
-
-h, --help Print this help and exit
|
|
243
|
-
-V, --version Print version and exit
|
|
244
247
|
```
|
|
245
248
|
|
|
246
249
|
### Examples
|
|
247
250
|
|
|
248
251
|
```bash
|
|
249
|
-
#
|
|
250
|
-
npx ironmark
|
|
251
|
-
npx ironmark
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
# Render as HTML (default)
|
|
253
|
+
echo '# Hello' | npx ironmark
|
|
254
|
+
npx ironmark README.md
|
|
255
|
+
|
|
256
|
+
# Render as ANSI terminal output
|
|
257
|
+
npx ironmark --format ansi README.md
|
|
258
|
+
npx ironmark --format ansi --width 120 README.md
|
|
259
|
+
npx ironmark --format ansi --no-color README.md | less
|
|
260
|
+
|
|
261
|
+
# Render as AST (JSON)
|
|
262
|
+
npx ironmark --format ast README.md
|
|
254
263
|
|
|
255
264
|
# Rust (after cargo install ironmark --features cli)
|
|
256
|
-
|
|
257
|
-
ironmark --ansi
|
|
258
|
-
|
|
259
|
-
cat doc.md | ironmark --ansi --math --wiki-links
|
|
265
|
+
echo '# Hello' | ironmark
|
|
266
|
+
ironmark --format ansi README.md
|
|
267
|
+
ironmark --format ansi --width 120 README.md
|
|
268
|
+
cat doc.md | ironmark --format ansi --math --wiki-links
|
|
260
269
|
```
|
|
261
270
|
|
|
262
271
|
## Rust
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ironmark",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "Very fast markdown parser in Rust, consumable from JavaScript/TypeScript via WebAssembly",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"conventional-changelog-conventionalcommits": "^9.3.1",
|
|
76
76
|
"markdown-wasm": "^1.2.0",
|
|
77
77
|
"md4w": "^0.2.7",
|
|
78
|
-
"oxfmt": "^0.
|
|
79
|
-
"oxlint": "^1.
|
|
78
|
+
"oxfmt": "^0.45.0",
|
|
79
|
+
"oxlint": "^1.60.0",
|
|
80
80
|
"semantic-release": "^25.0.3"
|
|
81
81
|
},
|
|
82
82
|
"engines": {
|
package/wasm/cli.js
CHANGED
|
@@ -1,49 +1,53 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
|
-
import { renderAnsi } from "./node.js";
|
|
3
|
+
import { parse, parseToAst, renderAnsi } from "./node.js";
|
|
4
4
|
|
|
5
5
|
const VERSION = JSON.parse(
|
|
6
6
|
readFileSync(new URL("../package.json", import.meta.url), "utf8"),
|
|
7
7
|
).version;
|
|
8
8
|
|
|
9
|
-
const HELP = `ironmark — render Markdown
|
|
9
|
+
const HELP = `ironmark — render Markdown in various output formats
|
|
10
10
|
|
|
11
11
|
USAGE:
|
|
12
|
-
ironmark --ansi [OPTIONS] [FILE...]
|
|
12
|
+
ironmark [--format <html|ansi|ast>] [OPTIONS] [FILE...]
|
|
13
13
|
|
|
14
14
|
When no FILE is given, reads from stdin. Use '-' for stdin explicitly.
|
|
15
|
+
Default format is html.
|
|
15
16
|
|
|
16
|
-
OPTIONS:
|
|
17
|
-
--ansi
|
|
17
|
+
OPTIONS (all formats):
|
|
18
|
+
--format <html|ansi|ast> Output format; ast also accepts 'json' (default: html)
|
|
19
|
+
--no-hard-breaks Don't turn soft newlines into hard line breaks
|
|
20
|
+
--no-tables Disable pipe table syntax
|
|
21
|
+
--no-highlight Disable ==highlight== syntax
|
|
22
|
+
--no-strikethrough Disable ~~strikethrough~~ syntax
|
|
23
|
+
--no-underline Disable ++underline++ syntax
|
|
24
|
+
--no-autolink Disable bare URL auto-linking
|
|
25
|
+
--no-task-lists Disable - [x] task list syntax
|
|
26
|
+
--math Enable $inline$ and $$display$$ math
|
|
27
|
+
--wiki-links Enable [[wiki link]] syntax
|
|
28
|
+
-h, --help Print this help and exit
|
|
29
|
+
-V, --version Print version and exit
|
|
30
|
+
|
|
31
|
+
OPTIONS (ansi format only):
|
|
18
32
|
--width N Terminal column width (default: auto-detect, fallback 80)
|
|
19
33
|
--no-color Disable ANSI escape codes (plain text)
|
|
20
34
|
-n, --line-numbers Show line numbers in fenced code blocks
|
|
21
35
|
--padding N Horizontal padding on both sides of output (default: 0)
|
|
22
|
-
--no-hard-breaks Don't turn soft newlines into hard line breaks
|
|
23
|
-
--no-tables Disable pipe table syntax
|
|
24
|
-
--no-highlight Disable ==highlight== syntax
|
|
25
|
-
--no-strikethrough Disable ~~strikethrough~~ syntax
|
|
26
|
-
--no-underline Disable ++underline++ syntax
|
|
27
|
-
--no-autolink Disable bare URL auto-linking
|
|
28
|
-
--no-task-lists Disable - [x] task list syntax
|
|
29
|
-
--math Enable $inline$ and $$display$$ math
|
|
30
|
-
--wiki-links Enable [[wiki link]] syntax
|
|
31
|
-
-h, --help Print this help and exit
|
|
32
|
-
-V, --version Print version and exit
|
|
33
36
|
|
|
34
37
|
EXAMPLES:
|
|
35
|
-
npx ironmark
|
|
36
|
-
npx ironmark --
|
|
37
|
-
npx ironmark --ansi
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
echo '# Hello' | npx ironmark
|
|
39
|
+
echo '# Hello' | npx ironmark --format html
|
|
40
|
+
npx ironmark --format ansi README.md
|
|
41
|
+
npx ironmark --format ast README.md
|
|
42
|
+
npx ironmark --format ansi --width 120 --no-color README.md | less
|
|
43
|
+
cat doc.md | npx ironmark --format ansi --math --wiki-links
|
|
40
44
|
`;
|
|
41
45
|
|
|
42
46
|
const args = process.argv.slice(2);
|
|
43
47
|
const files = [];
|
|
44
48
|
const parseOptions = {};
|
|
45
49
|
const ansiOptions = {};
|
|
46
|
-
let
|
|
50
|
+
let format = null;
|
|
47
51
|
|
|
48
52
|
for (let i = 0; i < args.length; i++) {
|
|
49
53
|
switch (args[i]) {
|
|
@@ -57,9 +61,15 @@ for (let i = 0; i < args.length; i++) {
|
|
|
57
61
|
console.log(`ironmark ${VERSION}`);
|
|
58
62
|
process.exit(0);
|
|
59
63
|
break;
|
|
60
|
-
case "--
|
|
61
|
-
|
|
64
|
+
case "--format": {
|
|
65
|
+
const val = args[++i];
|
|
66
|
+
if (val === undefined) {
|
|
67
|
+
console.error("error: --format requires a value");
|
|
68
|
+
process.exit(2);
|
|
69
|
+
}
|
|
70
|
+
format = val;
|
|
62
71
|
break;
|
|
72
|
+
}
|
|
63
73
|
case "--no-color":
|
|
64
74
|
case "--no-colour":
|
|
65
75
|
ansiOptions.color = false;
|
|
@@ -114,7 +124,9 @@ for (let i = 0; i < args.length; i++) {
|
|
|
114
124
|
parseOptions.enableWikiLinks = true;
|
|
115
125
|
break;
|
|
116
126
|
default:
|
|
117
|
-
if (args[i].startsWith("--
|
|
127
|
+
if (args[i].startsWith("--format=")) {
|
|
128
|
+
format = args[i].slice("--format=".length);
|
|
129
|
+
} else if (args[i].startsWith("--width=")) {
|
|
118
130
|
const val = Number(args[i].slice("--width=".length));
|
|
119
131
|
if (Number.isNaN(val)) {
|
|
120
132
|
console.error("error: --width requires a numeric value");
|
|
@@ -138,13 +150,20 @@ for (let i = 0; i < args.length; i++) {
|
|
|
138
150
|
}
|
|
139
151
|
}
|
|
140
152
|
|
|
141
|
-
|
|
142
|
-
|
|
153
|
+
const fmt = format ?? "html";
|
|
154
|
+
|
|
155
|
+
if (fmt !== "html" && fmt !== "ansi" && fmt !== "ast" && fmt !== "json") {
|
|
156
|
+
console.error(`error: unknown format '${fmt}' — use html, ansi, or ast`);
|
|
157
|
+
process.exit(2);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (files.length === 0 && process.stdin.isTTY) {
|
|
161
|
+
console.error("error: no input provided");
|
|
143
162
|
console.error("Run 'ironmark --help' for usage.");
|
|
144
163
|
process.exit(2);
|
|
145
164
|
}
|
|
146
165
|
|
|
147
|
-
// Auto-detect terminal width
|
|
166
|
+
// Auto-detect terminal width for ansi format
|
|
148
167
|
if (ansiOptions.width === undefined) {
|
|
149
168
|
ansiOptions.width = process.stdout.columns || 80;
|
|
150
169
|
}
|
|
@@ -168,4 +187,10 @@ if (files.length === 0) {
|
|
|
168
187
|
}
|
|
169
188
|
}
|
|
170
189
|
|
|
171
|
-
|
|
190
|
+
if (fmt === "html") {
|
|
191
|
+
process.stdout.write(parse(input, parseOptions));
|
|
192
|
+
} else if (fmt === "ansi") {
|
|
193
|
+
process.stdout.write(renderAnsi(input, parseOptions, ansiOptions));
|
|
194
|
+
} else {
|
|
195
|
+
process.stdout.write(JSON.stringify(parseToAst(input, parseOptions), null, 2) + "\n");
|
|
196
|
+
}
|