Expand description
Define, validate, and render typed Markdown extensions.
mdforge is built for applications that ask an LLM to produce Markdown-like
text but still need strong control over the structure. You define the
allowed block and inline extensions first, then run generated content through
parse, validate, eval, and a renderer.
§Example
use mdforge::{ArgType, EvalContext, Forge};
let forge = Forge::builder()
.block("card")
.arg("title", ArgType::String.required())
.body_markdown()
.register()
.inline("badge")
.arg("level", ArgType::Int.required())
.register()
.build();
let input = ":::card title=hello\nBody {badge level=2}\n:::\n";
let doc = forge.parse(input).expect("parse");
forge.validate(&doc).expect("validate");
forge.eval(&doc, &EvalContext::default()).expect("eval");
assert!(forge.signature().contains("Block: card"));See docs/user_guide.md in the repository for a longer walkthrough.
Re-exports§
pub use ast::ArgType;pub use ast::ArgValue;pub use ast::BlockNode;pub use ast::Document;pub use ast::InlineExt;pub use ast::MdEvent;pub use ast::Node;pub use ast::Span;pub use diagnostic::Diagnostic;pub use diagnostic::ErrorCode;pub use diagnostic::Level;pub use dom::VElement;pub use dom::VNode;pub use forge::EvalContext;pub use forge::Forge;pub use forge::ForgeBuilder;pub use forge::HtmlRenderer;
Modules§
- ast
- Abstract syntax tree types.
- diagnostic
- Structured diagnostics produced by parsing, validation, and evaluation.
- dom
- Lightweight DOM-like output nodes.
- forge
- Forge builders, pipeline methods, and renderer traits.