ironmark 1.1.0 → 1.1.2
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 +49 -81
- package/package.json +3 -3
- package/wasm/node.js +1 -1
- package/wasm/pkg/ironmark_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
# ironmark
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- Zero third-party parsing dependencies
|
|
8
|
-
- Headings (`#` through `######`) and setext headings
|
|
9
|
-
- Paragraphs, emphasis, strong emphasis, inline code
|
|
10
|
-
- ~~strikethrough~~, ==highlight==, ++underline++
|
|
11
|
-
- Links, reference links, autolinks (angle-bracket and bare URL/email), images
|
|
12
|
-
- Ordered and unordered lists with nesting, task lists (checkboxes)
|
|
13
|
-
- Blockquotes, horizontal rules
|
|
14
|
-
- Fenced and indented code blocks
|
|
15
|
-
- Tables with alignment
|
|
16
|
-
- Raw HTML passthrough
|
|
17
|
-
- Backslash escapes and HTML entities
|
|
3
|
+
[](https://github.com/ph1p/ironmark/actions/workflows/ci.yml) [](https://www.npmjs.com/package/ironmark) [](https://crates.io/crates/ironmark)
|
|
18
4
|
|
|
19
|
-
|
|
5
|
+
Fast Markdown-to-HTML parser written in Rust with **zero third-party** parsing dependencies. Fully compliant with [CommonMark 0.31.2](https://spec.commonmark.org/0.31.2/) (652/652 spec tests pass). Available as a Rust crate and as an npm package via WebAssembly.
|
|
6
|
+
|
|
7
|
+
## Options
|
|
8
|
+
|
|
9
|
+
All options default to `true`.
|
|
10
|
+
|
|
11
|
+
| Option | JS (`camelCase`) | Rust (`snake_case`) | Description |
|
|
12
|
+
| ------------- | --------------------- | ---------------------- | ------------------------------ |
|
|
13
|
+
| Hard breaks | `hardBreaks` | `hard_breaks` | Every newline becomes `<br />` |
|
|
14
|
+
| Highlight | `enableHighlight` | `enable_highlight` | `==text==` → `<mark>` |
|
|
15
|
+
| Strikethrough | `enableStrikethrough` | `enable_strikethrough` | `~~text~~` → `<del>` |
|
|
16
|
+
| Underline | `enableUnderline` | `enable_underline` | `++text++` → `<u>` |
|
|
17
|
+
| Tables | `enableTables` | `enable_tables` | Pipe table syntax |
|
|
18
|
+
| Autolink | `enableAutolink` | `enable_autolink` | Bare URLs & emails → `<a>` |
|
|
19
|
+
| Task lists | `enableTaskLists` | `enable_task_lists` | `- [ ]` / `- [x]` checkboxes |
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
## JavaScript / TypeScript
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
npm install ironmark
|
|
25
|
+
# or
|
|
26
|
+
pnpm add ironmark
|
|
25
27
|
```
|
|
26
28
|
|
|
27
|
-
###
|
|
29
|
+
### Node.js
|
|
28
30
|
|
|
29
31
|
WASM is embedded and loaded synchronously — no `init()` needed:
|
|
30
32
|
|
|
@@ -32,14 +34,11 @@ WASM is embedded and loaded synchronously — no `init()` needed:
|
|
|
32
34
|
import { parse } from "ironmark";
|
|
33
35
|
|
|
34
36
|
const html = parse("# Hello\n\nThis is **fast**.");
|
|
35
|
-
|
|
36
|
-
const bytes = new TextEncoder().encode("# Hello from bytes");
|
|
37
|
-
const html2 = parse(bytes);
|
|
38
37
|
```
|
|
39
38
|
|
|
40
|
-
###
|
|
39
|
+
### Browser / Bundler
|
|
41
40
|
|
|
42
|
-
Call `init()` once before using `parse()
|
|
41
|
+
Call `init()` once before using `parse()`. It's idempotent and optionally accepts a custom `.wasm` URL.
|
|
43
42
|
|
|
44
43
|
```ts
|
|
45
44
|
import { init, parse } from "ironmark";
|
|
@@ -49,90 +48,59 @@ await init();
|
|
|
49
48
|
const html = parse("# Hello\n\nThis is **fast**.");
|
|
50
49
|
```
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
### Options
|
|
51
|
+
#### Vite
|
|
55
52
|
|
|
56
53
|
```ts
|
|
57
|
-
import { parse } from "ironmark";
|
|
58
|
-
|
|
59
|
-
const html = parse("line one\nline two", {
|
|
60
|
-
hardBreaks: false, // every newline becomes <br /> (default: true)
|
|
61
|
-
enableHighlight: true, // ==highlight== → <mark> (default: true)
|
|
62
|
-
enableStrikethrough: true, // ~~strike~~ → <del> (default: true)
|
|
63
|
-
enableUnderline: true, // ++underline++ → <u> (default: true)
|
|
64
|
-
enableTables: true, // pipe tables (default: true)
|
|
65
|
-
enableAutolink: true, // bare URLs & emails → <a> (default: true)
|
|
66
|
-
enableTaskLists: true, // - [ ] / - [x] checkboxes (default: true)
|
|
67
|
-
});
|
|
68
|
-
```
|
|
54
|
+
import { init, parse } from "ironmark";
|
|
55
|
+
import wasmUrl from "ironmark/ironmark.wasm?url";
|
|
69
56
|
|
|
70
|
-
|
|
57
|
+
await init(wasmUrl);
|
|
71
58
|
|
|
72
|
-
|
|
73
|
-
npm run setup:wasm
|
|
74
|
-
npm run build
|
|
59
|
+
const html = parse("# Hello\n\nThis is **fast**.");
|
|
75
60
|
```
|
|
76
61
|
|
|
77
|
-
| Command | Description |
|
|
78
|
-
| -------------------- | ---------------------- |
|
|
79
|
-
| `npm run setup:wasm` | Install prerequisites |
|
|
80
|
-
| `npm run build` | Release WASM build |
|
|
81
|
-
| `npm run build:dev` | Debug WASM build |
|
|
82
|
-
| `npm run test` | Run Rust tests |
|
|
83
|
-
| `npm run check` | Format check + tests |
|
|
84
|
-
| `npm run clean` | Remove build artifacts |
|
|
85
|
-
|
|
86
62
|
## Rust
|
|
87
63
|
|
|
88
|
-
### Add to your project
|
|
89
|
-
|
|
90
64
|
```bash
|
|
91
65
|
cargo add ironmark
|
|
92
66
|
```
|
|
93
67
|
|
|
94
|
-
### Usage
|
|
95
|
-
|
|
96
68
|
```rust
|
|
97
69
|
use ironmark::{parse, ParseOptions};
|
|
98
70
|
|
|
99
71
|
fn main() {
|
|
72
|
+
// with defaults
|
|
100
73
|
let html = parse("# Hello\n\nThis is **fast**.", &ParseOptions::default());
|
|
101
|
-
println!("{html}");
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### With options
|
|
106
|
-
|
|
107
|
-
```rust
|
|
108
|
-
use ironmark::{parse, ParseOptions};
|
|
109
74
|
|
|
110
|
-
|
|
111
|
-
let
|
|
112
|
-
hard_breaks:
|
|
113
|
-
enable_strikethrough: false,
|
|
114
|
-
enable_autolink: true, // bare URLs & emails → <a>
|
|
115
|
-
enable_task_lists: true, // - [ ] / - [x] checkboxes
|
|
75
|
+
// with custom options
|
|
76
|
+
let html = parse("line one\nline two", &ParseOptions {
|
|
77
|
+
hard_breaks: false,
|
|
78
|
+
enable_strikethrough: false,
|
|
116
79
|
..Default::default()
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
let html = parse("line one\nline two", &options);
|
|
120
|
-
println!("{html}");
|
|
80
|
+
});
|
|
121
81
|
}
|
|
122
82
|
```
|
|
123
83
|
|
|
124
|
-
##
|
|
84
|
+
## Development
|
|
125
85
|
|
|
126
|
-
|
|
86
|
+
This project uses [pnpm](https://pnpm.io/) for package management.
|
|
127
87
|
|
|
128
|
-
|
|
88
|
+
### Build from source
|
|
129
89
|
|
|
130
90
|
```bash
|
|
131
|
-
|
|
91
|
+
pnpm setup:wasm
|
|
92
|
+
pnpm build
|
|
132
93
|
```
|
|
133
94
|
|
|
134
|
-
|
|
95
|
+
| Command | Description |
|
|
96
|
+
| ----------------- | ---------------------- |
|
|
97
|
+
| `pnpm setup:wasm` | Install prerequisites |
|
|
98
|
+
| `pnpm build` | Release WASM build |
|
|
99
|
+
| `pnpm build:dev` | Debug WASM build |
|
|
100
|
+
| `pnpm test` | Run Rust tests |
|
|
101
|
+
| `pnpm check` | Format check |
|
|
102
|
+
| `pnpm clean` | Remove build artifacts |
|
|
135
103
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
104
|
+
### Troubleshooting
|
|
105
|
+
|
|
106
|
+
**`wasm32-unknown-unknown target not found`** or **`wasm-bindgen not found`** — run `pnpm setup:wasm` to install all prerequisites.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ironmark",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Very fast markdown parser in Rust, consumable from JavaScript/TypeScript via WebAssembly",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"default": "./wasm/web.js"
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
"./wasm
|
|
44
|
+
"./ironmark.wasm": "./wasm/pkg/ironmark_bg.wasm"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"build": "npm run build:wasm && node wasm/build.mjs",
|
|
52
52
|
"build:dev": "PATH=\"$PWD/.wasm-tools/bin:$HOME/.cargo/bin:$PATH\" cargo build -p ironmark-wasm --target wasm32-unknown-unknown && PATH=\"$PWD/.wasm-tools/bin:$HOME/.cargo/bin:$PATH\" wasm-bindgen --target bundler --out-dir wasm/pkg --out-name ironmark target/wasm32-unknown-unknown/debug/ironmark.wasm && node wasm/build.mjs",
|
|
53
53
|
"build:wasm": "PATH=\"$PWD/.wasm-tools/bin:$HOME/.cargo/bin:$PATH\" cargo build -p ironmark-wasm --release --target wasm32-unknown-unknown && PATH=\"$PWD/.wasm-tools/bin:$HOME/.cargo/bin:$PATH\" wasm-bindgen --target bundler --out-dir wasm/pkg --out-name ironmark target/wasm32-unknown-unknown/release/ironmark.wasm && wasm-opt --enable-bulk-memory -O3 wasm/pkg/ironmark_bg.wasm -o wasm/pkg/ironmark_bg.wasm",
|
|
54
|
-
"check": "cargo fmt --check &&
|
|
54
|
+
"check": "cargo fmt --check && oxlint && oxfmt --check .",
|
|
55
55
|
"clean": "rm -rf wasm/pkg .wasm-tools",
|
|
56
56
|
"fmt": "cargo fmt && oxfmt --write .",
|
|
57
57
|
"lint": "oxlint",
|