Skip to content

Commit eadf59d

Browse files
Jonathan D.A. Jewellclaude
andcommitted
feat(core): FD-S02, FD-S03 - Add RST and Typst format handlers
SHOULD requirements implemented: - FD-S02: reStructuredText handler using document_tree crate - Parser converts RST elements to unified AST - Renderer outputs RST from AST - Handles headings, paragraphs, lists, code blocks, emphasis - FD-S03: Typst handler using typst-syntax crate - Parser converts Typst syntax to unified AST - Renderer outputs Typst markup from AST - Supports math blocks, figures, bibliography features Both handlers implement Parser, Renderer, and FormatHandler traits. FFI layer updated for Ada TUI integration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8157b94 commit eadf59d

4 files changed

Lines changed: 1241 additions & 3 deletions

File tree

crates/formatrix-core/src/ffi.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,22 @@ pub unsafe extern "C" fn formatrix_parse(
120120
Err(_) => return FfiResult::ParseError,
121121
}
122122
}
123+
// FD-S02: RST support
124+
SourceFormat::ReStructuredText => {
125+
use crate::formats::RstHandler;
126+
match RstHandler::new().parse(content_str, &config) {
127+
Ok(d) => d,
128+
Err(_) => return FfiResult::ParseError,
129+
}
130+
}
131+
// FD-S03: Typst support
132+
SourceFormat::Typst => {
133+
use crate::formats::TypstHandler;
134+
match TypstHandler::new().parse(content_str, &config) {
135+
Ok(d) => d,
136+
Err(_) => return FfiResult::ParseError,
137+
}
138+
}
123139
_ => return FfiResult::UnsupportedFormat,
124140
};
125141

@@ -179,6 +195,22 @@ pub unsafe extern "C" fn formatrix_render(
179195
Err(_) => return FfiResult::RenderError,
180196
}
181197
}
198+
// FD-S02: RST support
199+
SourceFormat::ReStructuredText => {
200+
use crate::formats::RstHandler;
201+
match RstHandler::new().render(doc, &config) {
202+
Ok(s) => s,
203+
Err(_) => return FfiResult::RenderError,
204+
}
205+
}
206+
// FD-S03: Typst support
207+
SourceFormat::Typst => {
208+
use crate::formats::TypstHandler;
209+
match TypstHandler::new().render(doc, &config) {
210+
Ok(s) => s,
211+
Err(_) => return FfiResult::RenderError,
212+
}
213+
}
182214
_ => return FfiResult::UnsupportedFormat,
183215
};
184216

crates/formatrix-core/src/formats/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ pub mod markdown;
66
pub mod djot;
77
pub mod orgmode;
88

9-
// These will be implemented incrementally
9+
// FD-S02, FD-S03: SHOULD requirement implementations
10+
pub mod rst;
11+
pub mod typst;
12+
13+
// FD-S01: AsciiDoc - to be implemented
1014
// pub mod asciidoc;
11-
// pub mod rst;
12-
// pub mod typst;
1315

1416
pub use plaintext::PlainTextHandler;
1517
pub use markdown::MarkdownHandler;
1618
pub use djot::DjotHandler;
1719
pub use orgmode::OrgModeHandler;
20+
21+
// SHOULD handlers
22+
pub use rst::RstHandler;
23+
pub use typst::TypstHandler;

0 commit comments

Comments
 (0)