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 pager;
30pub mod paragraph;
31pub mod parser;
32pub mod test_helpers;
33pub mod writer;
34
35pub use document::Document;
36pub use inline::{InlineStyle, Span};
37pub use pager::*;
38pub use paragraph::{ChecklistItem, Paragraph, ParagraphType};
39pub use parser::parse;
40pub use writer::write;
41
42/// Convenience result type used across parsing and writing APIs.
43pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;