tdoc/lib.rs
1//! tdoc is a toolkit for building, parsing, formatting, and exporting FTML
2//! (Formatted Text Markup Language) documents.
3//!
4//! The crate is centered around three core concepts:
5//! - [`Document`], [`Paragraph`], and [`Span`], which form an in-memory tree
6//! representation of FTML content.
7//! - Parsers (see [`parser`], [`html`], [`markdown`], and [`gemini`]) that turn external text
8//! into that tree.
9//! - Writers and formatters (see [`writer`] and [`formatter`]) that turn the tree
10//! back into HTML, Markdown, Gemini, or richly styled terminal output.
11//!
12//! Checklists (Markdown `- [ ]` entries or HTML `<input type="checkbox">`
13//! lists) map to [`ParagraphType::Checklist`] nodes that store [`ChecklistItem`]
14//! children. Nested checklist items are preserved end-to-end so complex task
15//! hierarchies round-trip across every parser and writer.
16//!
17//! Most applications start by building a [`Document`] manually or converting
18//! some source text via [`parse`], manipulate or inspect the tree, and finally
19//! render it with [`writer::Writer`] or [`formatter::Formatter`].
20
21mod macros;
22
23pub mod document;
24pub mod formatter;
25pub mod gemini;
26pub mod html;
27pub mod inline;
28pub mod markdown;
29pub mod metadata;
30pub mod pager;
31pub mod paragraph;
32pub mod parser;
33pub mod test_helpers;
34pub mod writer;
35
36pub use document::Document;
37pub use inline::{InlineStyle, Span};
38pub use pager::*;
39pub use paragraph::{ChecklistItem, Paragraph, ParagraphType};
40pub use parser::parse;
41pub use writer::write;
42
43/// Convenience result type used across parsing and writing APIs.
44pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;