ironmark 1.2.0 → 1.3.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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![CI](https://github.com/ph1p/ironmark/actions/workflows/ci.yml/badge.svg)](https://github.com/ph1p/ironmark/actions/workflows/ci.yml) [![npm](https://img.shields.io/npm/v/ironmark)](https://www.npmjs.com/package/ironmark) [![crates.io](https://img.shields.io/crates/v/ironmark)](https://crates.io/crates/ironmark)
4
4
 
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.
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, with both HTML and AST output APIs.
6
6
 
7
7
  ## Options
8
8
 
@@ -36,6 +36,19 @@ import { parse } from "ironmark";
36
36
  const html = parse("# Hello\n\nThis is **fast**.");
37
37
  ```
38
38
 
39
+ ### AST Output
40
+
41
+ Use `parseToAst()` when you need the block-level document structure instead of rendered HTML.
42
+
43
+ ```ts
44
+ import { parseToAst } from "ironmark";
45
+
46
+ const astJson = parseToAst("# Hello\n\n- [x] done");
47
+ const ast = JSON.parse(astJson);
48
+ ```
49
+
50
+ `parseToAst()` returns a JSON string for portability across JS runtimes and WASM boundaries.
51
+
39
52
  ### Browser / Bundler
40
53
 
41
54
  Call `init()` once before using `parse()`. It's idempotent and optionally accepts a custom `.wasm` URL.
@@ -81,6 +94,32 @@ fn main() {
81
94
  }
82
95
  ```
83
96
 
97
+ ### AST Output
98
+
99
+ `parse_to_ast()` returns the typed Rust AST (`Block`) directly:
100
+
101
+ ```rust
102
+ use ironmark::{Block, ParseOptions, parse_to_ast};
103
+
104
+ fn main() {
105
+ let ast = parse_to_ast("# Hello", &ParseOptions::default());
106
+
107
+ match ast {
108
+ Block::Document { children } => {
109
+ println!("top-level blocks: {}", children.len());
110
+ }
111
+ _ => unreachable!("root node is always Document"),
112
+ }
113
+ }
114
+ ```
115
+
116
+ Exported AST types:
117
+
118
+ - `Block`
119
+ - `ListKind`
120
+ - `TableData`
121
+ - `TableAlignment`
122
+
84
123
  ## Development
85
124
 
86
125
  This project uses [pnpm](https://pnpm.io/) for package management.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ironmark",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Very fast markdown parser in Rust, consumable from JavaScript/TypeScript via WebAssembly",
5
5
  "keywords": [
6
6
  "markdown",
@@ -57,7 +57,7 @@
57
57
  "lint": "oxlint",
58
58
  "release": "semantic-release",
59
59
  "release:dry": "semantic-release --dry-run",
60
- "setup:wasm": "PATH=\"$HOME/.cargo/bin:$PATH\" rustup target add wasm32-unknown-unknown && TMPDIR=/tmp PATH=\"$HOME/.cargo/bin:$PATH\" cargo install wasm-bindgen-cli --locked --root .wasm-tools",
60
+ "setup:wasm": "PATH=\"$HOME/.cargo/bin:$PATH\" rustup target add wasm32-unknown-unknown && TMPDIR=/tmp PATH=\"$HOME/.cargo/bin:$PATH\" cargo install wasm-bindgen-cli --version 0.2.113 --locked --root .wasm-tools",
61
61
  "bench": "cargo bench && node benchmark/report.mjs",
62
62
  "test": "cargo test --offline"
63
63
  },