docloom
A Rust library for programmatically building and rendering documents to markdown and styled terminal output.
Install
Usage
use *;
use ;
let blocks = ;
let markdown = doc;
let terminal = doc;
println!;
println!;
Apply renderer-specific styling with .with_style(...) before calling .to_string().
Document Structure
Documents are built from Block and Inline elements.
Block Elements
Paragraph(Vec<Inline>)- Text paragraphHeading { level, content }- Headers (h1-h6)CodeBlock { language, content }- Fenced code blocksList { ordered, items }- Ordered/unordered listsTaskList { items }- Checkbox listsTable { headers, rows, alignments }- Tables with alignmentImage { alt, url }- Standalone image blocksBlockquote(Vec<Block>)- Quoted blocksHorizontalRule- Horizontal dividerBlockList(Vec<Block>)- Container for multiple blocks
Inline Elements
Text(String)- Plain textBold(Vec<Inline>)- Bold formattingItalic(Vec<Inline>)- Italic formattingStrikethrough(Vec<Inline>)-StrikethroughformattingCode(String)-Inline codeLink { text, url }- HyperlinksImage { alt, url }- Inline imagesLineBreak- Line break
Builder Functions
Block Builders
use *;
// Headers
h1;
h2; // ... through h6
// Content
p;
code_block;
quote;
hr; // horizontal rule
// Lists
ul; // unordered
ol; // ordered
task_list;
// Tables
table;
table;
Inline Builders
use *;
text;
bold;
italic;
strikethrough;
code;
link;
Extension Traits
Use method syntax with BlockExt and InlineExt:
use *;
"Title".h1;
"Paragraph".p;
"text".bold;
"text".italic;
"link text".link;
Renderers
Markdown Renderer
Outputs standard markdown with configurable styles:
use ;
let style = Style ;
let _content = doc.with_style;
Terminal Renderer
Outputs styled terminal output with ANSI codes:
use ;
let style = plain
.unicode_boxes
.colors
.heading_colors;
let _plain = doc.with_style;
let _ascii = doc.with_style;
Terminal features:
- Colored headers, code, links
- Unicode or ASCII box drawing
- Table alignment support
- Indented lists and blockquotes
Tuple Convenience
Build content from tuples for concise syntax:
use *;
// Multiple inline elements from tuple
p;
// Table rows from nested tuples
table;
Custom Rendering
Implement the Render trait for custom output formats:
use ;
use fmt;
;
📄 License
MIT © Dan Beaven