facett-markdown — design note
Status: builds (egui 0.33) + 5 tests green. In ordning/crates/widgets/facett-markdown; destined for facett.
What it is
A Markdown editor + preview for case descriptions and comments, with @mention and #tag extraction (for the host to link/notify) and highlighting. Edit/Preview toggle. A pragmatic, dependency-free renderer (no markdown crate — the subset a case uses is small; hand-rolling keeps the lean-Rust stance).
API
let mut md = Markdown::new("Description").with_text("# Title\n@maria see #regression");
md.ui(ui); // edit/preview
let people = md.mentions(); // ["maria"] (unique, first-seen order, Swedish letters OK)
let tags = md.tags(); // ["regression"]
let source = md.text();
Rendering subset
Headings (#/##/###), bullet + numbered lists, blockquotes (>), code fences (```), and inline bold, code, [text](url) links, @mention, #tag. Rendered via egui LayoutJob for mixed inline styles.
Design decisions
- @/# must start a word (so
user@example.comandfoo#barare NOT mentions/tags); word chars include SwedishåäöÅÄÖ+_-. Tested. - Links/headings use the Tillsynia-yellow accent; mentions blue, tags green, code on a dark bg.
state_jsonexposes mode, char count, mentions, tags → headless-observable.
Move-to-facett / TODO
- Bold currently isn't truly bold (egui needs a bold font variant) — emulated; the facett version uses the theme's strong font. Same for theme-driven colors.
- @mention / #tag autocomplete dropdown while typing in edit mode (needs the host's user/tag list).
- Tables, images, task-list checkboxes; or swap to
pulldown-cmarkif the subset proves too small — but the current hand-rolled renderer has zero deps, which fits the lean stance.