Expand description
leaf-core — the frontend-neutral heart of leaf.
A Doc is a twig::Editor plus a byte-offset caret and selection: every
mutation is one of twig’s offset-addressed ops, and the document stays a
live, round-trippable AST the whole time you type into it. The wysiwyg
module resolves that AST into a wysiwyg::VisualMap — rendered glyphs that
each point back at the source byte they came from, so a caret can ride the
visible text and step over hidden markup delimiters.
Nothing here depends on a UI toolkit. Glyphs carry a toolkit-agnostic
Style, which a frontend crate (leaf-tui, and next leaf-gui) maps onto
its own styling. Both frontends share this exact caret math, edit surface,
and offset⇄position mapping — the split is what lets a GUI reuse the hard
parts instead of re-deriving them.
Re-exports§
pub use doc::Capabilities;pub use doc::DiskState;pub use doc::Doc;pub use doc::FootnoteDef;pub use doc::FootnoteRef;pub use doc::InlineMarks;pub use doc::Landing;pub use doc::LineFlow;pub use doc::MarkupMode;pub use doc::View;pub use style::Baseline;pub use style::Role;pub use style::Style;pub use wysiwyg::BlockClass;pub use wysiwyg::Boundary;pub use wysiwyg::CodeBlockInfo;pub use wysiwyg::ColorScheme;pub use wysiwyg::Glyph;pub use wysiwyg::MediaInfo;pub use wysiwyg::MediaKind;pub use wysiwyg::MediaSource;pub use wysiwyg::TableCell;pub use wysiwyg::TableInfo;pub use wysiwyg::TableRow;pub use wysiwyg::VRow;pub use wysiwyg::VisualMap;
Modules§
- doc
- The document model: a
twig::Editorplus a byte-offset caret and selection. - style
- A toolkit-neutral text style — the seam that lets one document model drive any frontend.
- wysiwyg
- The WYSIWYG view: render the document with its markup resolved, not shown —
headings and code tagged with a typographic role (a frontend sizes or colours
them; see
crate::style),**bold**as real bold,#/**/`delimiters hidden — while keeping every visible glyph tied back to the source byte it came from.
Enums§
- Alignment
- Table-cell alignment: written via
Builder::add_cell, read back onFlatNode::alignment. - Block
Container Kind - A block container for
Editor::toggle_block_container— the toolbar’s Quote / Bulleted list / Numbered list buttons. Where aBlockKindrewrites one block’s leading marker, a container prefixes every line of a range and nests. Djot and Markdown spell all three; other formats yieldError::UnsupportedFormat. - Block
Kind - A block target for
Editor::set_block— the toolbar’s H1…H6 / Body switch. - Format
- Every format Twig can parse — the input axis, as opposed to
Target, which is where output bytes can go. - Gesture
- One authoring gesture, named with whatever kind it takes — the question
Format::supportsanswers. - Inline
Kind - An inline mark for
Editor::wrap_range/Editor::toggle_inline— a rich editor’s Bold / Italic / Code / … buttons. Markdown spells onlyInlineKind::Strong,InlineKind::Emph, andInlineKind::Verbatim; Djot spells all of them. An unsupported kind yieldsError::UnsupportedFormat.