Module text_detect
Expand description
Identifiers inside free text: links, email addresses, mentions and room aliases found in a run of prose.
The shaping path runs this over every TextKind::Prose run, so a link
in a chat message, an address in a mail body or a handle in a note is set
as what it is — TextKind::Url or TextKind::Identifier — with no
app involvement. Apps that want to act on the same spans (open a link,
resolve a mention) call identifier_spans and get exactly the ranges
the text is drawn with.
The scan is a pure function of the text: whitespace-separated words, trimmed of the punctuation prose wraps them in, then classified. It runs in one pass over the bytes and allocates only for what it finds.
Structs§
- Detected
Span - One identifier found in a run of text.
Enums§
- Detected
- What an identifier span is.
Functions§
- identifier_
kinds identifier_spansas(range, kind)pairs, for shaping.- identifier_
spans - Every link, email address, mention and room alias in
text, in order, as byte ranges on character boundaries.