Expand description
The markdown inline scanner.
Implements the restricted subset in docs/design.md “Markdown” —
**bold**, *italic* / _italic_, `code`, ~~strike~~,
[label](url), and backslash escapes. Block constructs (fenced code,
> quotes) are recognised by split_blocks before this scanner
runs; everything else CommonMark defines is deliberately absent.
Why hand-written rather than pulldown-cmark. Three reasons: it
has no inline-only mode, so we would be filtering
a block-level event stream and fighting CommonMark’s block rules to
suppress headings, thematic breaks and setext underlines — all of
which occur constantly in real chat prose (# 1, ---, ====); its
event stream would still need converting into byte-ranged
Spans, which is most of the work; and a scanner
for six constructs is small enough to be exhaustively tested and
predictable on pathological input.
What is deliberately not supported, and why: headings (# opens
far too many ordinary chat lines), images (![]() — inline media has
a server-validated upload/download pipeline and must not be
bypassable by an arbitrary URL), tables, raw HTML, reference links,
footnotes, thematic breaks, setext headings, and autolinking (that is
crate::linkify’s, which also supplies the scheme list a
[label](url) is checked against).
Structs§
- Source
Span - One tintable region of source text, for the compose box.
Enums§
- RawBlock
- A block-level piece of a message body.
Functions§
- parse_
inline - Parse inline markdown into styled text.
- parse_
inline_ with parse_inline, with[label](url)links checked againstlinksrather than the default scheme list.- scan_
delims - Locate the markdown delimiters in
srcthat will actually be consumed, reporting ranges in the source. - scheme_
allowed - Whether a
[label](url)link may point aturlunder the default scheme list. - split_
blocks - Split a message body into block-level pieces.