Skip to main content

Module style

Module style 

Source
Expand description

A toolkit-neutral text style — the seam that lets one document model drive any frontend.

The WYSIWYG builder (crate::wysiwyg) tags each rendered glyph with one of these instead of a ratatui::Style or a gpui::TextStyle, so the caret model and the AST→glyph layout stay free of any GUI/TUI dependency.

What core records is what a glyph is, never what color to paint it: a Role (heading, code, link, a list bullet, …) plus the portable emphasis the author actually wrote (**bold**, *em*, {+ins+}, {-del-}). Palette is presentation, and presentation belongs to the frontend — a terminal tells a heading from body text by color because color is all it can vary, while a GUI varies size and font instead. So each frontend maps a Role to its own look: leaf-tui turns it into terminal colors, leaf-gpui into an Hsla plus a font size and family. Core stays out of that argument.

Structs§

Style
A glyph’s style: a typographic Role plus the compositional emphasis flags the author wrote. Deliberately no color — that is a frontend’s call, keyed on the Role. Builder methods (.bold, .italic, …) mirror the shape of ratatui’s Style so the WYSIWYG builder reads the same as it did before the split.

Enums§

Align
How a block’s lines are set across the measure — the one presentation property an author reaches for before any other, and the only one of the six whose vocabulary is a class rather than a data- key.
Baseline
Which line a glyph sits on relative to the text around it.
FontFamily
The face a run is set in — CSS’s generic families, less fantasy and system-ui, neither of which an author asks for.
LineSpacing
How far apart a block’s lines are set, as a multiple of the theme’s own line height — the spacing menu every word processor has, less the single spacing that is absence.
MarkColor
The colour an author named on a highlight — the closed vocabulary twig records as a mark node’s data-color, one variant per circle emoji the ==🔴 text== spelling recognises.
Role
What a glyph is, typographically — the semantic role a frontend maps to its own presentation. Mutually exclusive per glyph (a glyph is a heading, or a link, or body text — not two at once); the compositional emphasis a run can also carry lives in Style’s bold/italic/underline/strikethrough flags alongside this.
SizeStep
How large a run is set relative to the text around it — CSS’s <absolute-size> keyword set with medium removed, because medium is absence.
Token
What a glyph in a fenced code block is to the language it is written in — the syntax-highlighting vocabulary, one level down from Role.