Skip to content

Commit d27efe5

Browse files
Jonathan D.A. Jewellclaude
andcommitted
feat(formatrix-core): FD-S01 AsciiDoc parser and renderer
Add asciidoc-parser v0.14 integration for AsciiDoc format support: - Parse AsciiDoc documents to unified AST - Render AST back to AsciiDoc format - Handle sections, paragraphs, code blocks, blockquotes - Handle media blocks, raw delimited blocks, breaks - C FFI support for Ada TUI integration - Feature flag 'asciidoc' for conditional compilation This completes the SHOULD requirements for all three secondary formats: RST (FD-S02), Typst (FD-S03), and AsciiDoc (FD-S01). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent eadf59d commit d27efe5

7 files changed

Lines changed: 650 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ orgize = { version = "0.9", features = ["chrono"] }
2929
rst_parser = "0.4"
3030
document_tree = "0.4"
3131
typst-syntax = "0.12"
32+
asciidoc-parser = "0.14"
3233

3334
# Database
3435
arangors = "0.6"

crates/formatrix-core/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ orgize.workspace = true
1919
rst_parser.workspace = true
2020
document_tree.workspace = true
2121
typst-syntax.workspace = true
22+
asciidoc-parser.workspace = true
2223

2324
# Serialization
2425
serde.workspace = true
@@ -35,10 +36,11 @@ pretty_assertions = "1.4"
3536
proptest = "1.5"
3637

3738
[features]
38-
default = ["markdown", "djot", "orgmode", "rst", "typst"]
39+
default = ["markdown", "djot", "orgmode", "rst", "typst", "asciidoc"]
3940
markdown = []
4041
djot = []
4142
orgmode = []
4243
rst = []
4344
typst = []
45+
asciidoc = []
4446
ffi = [] # Enable C FFI for Ada TUI

crates/formatrix-core/src/ffi.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ pub unsafe extern "C" fn formatrix_parse(
120120
Err(_) => return FfiResult::ParseError,
121121
}
122122
}
123+
// FD-S01: AsciiDoc support
124+
SourceFormat::AsciiDoc => {
125+
use crate::formats::AsciidocHandler;
126+
match AsciidocHandler::new().parse(content_str, &config) {
127+
Ok(d) => d,
128+
Err(_) => return FfiResult::ParseError,
129+
}
130+
}
123131
// FD-S02: RST support
124132
SourceFormat::ReStructuredText => {
125133
use crate::formats::RstHandler;
@@ -136,7 +144,6 @@ pub unsafe extern "C" fn formatrix_parse(
136144
Err(_) => return FfiResult::ParseError,
137145
}
138146
}
139-
_ => return FfiResult::UnsupportedFormat,
140147
};
141148

142149
let handle = Box::new(DocumentHandle { doc });
@@ -195,6 +202,14 @@ pub unsafe extern "C" fn formatrix_render(
195202
Err(_) => return FfiResult::RenderError,
196203
}
197204
}
205+
// FD-S01: AsciiDoc support
206+
SourceFormat::AsciiDoc => {
207+
use crate::formats::AsciidocHandler;
208+
match AsciidocHandler::new().render(doc, &config) {
209+
Ok(s) => s,
210+
Err(_) => return FfiResult::RenderError,
211+
}
212+
}
198213
// FD-S02: RST support
199214
SourceFormat::ReStructuredText => {
200215
use crate::formats::RstHandler;
@@ -211,7 +226,6 @@ pub unsafe extern "C" fn formatrix_render(
211226
Err(_) => return FfiResult::RenderError,
212227
}
213228
}
214-
_ => return FfiResult::UnsupportedFormat,
215229
};
216230

217231
let c_string = match CString::new(output.clone()) {

0 commit comments

Comments
 (0)