Skip to main content

Module marks

Module marks 

Source
Expand description

The inline marks an app spells itself.

Mark is closed — bold, italic, strike, code, links — because every one of those has a spelling CommonMark already reads. Underline, highlight and a colour do not, so they cannot be variants here without this crate inventing markdown for everyone. An app that wants them registers a name and the delimiter that spells it, and the parse and the serializer take it from there:

let marks = markdown::Marks::new().with("highlight", "==");
let doc = markdown::parse_with("a ==lit== word", &marks);
assert_eq!(markdown::serialize_with(&doc, &marks), "a ==lit== word");

The registry is a parameter rather than a global because parse_with and serialize_with are pure — the same reason the highlighter is a function pointer rather than a dependency. crate::AppExt::set_marks is the gpui-side half, for the editing surface, which has a cx and no other way to know.

A delimiter markdown already spells (*, _, `, ~, [) is yours to avoid: CommonMark reads it first and the registration never fires.

Structs§

Marks
The custom marks a document is read and written with.