Skip to main content

Module markdown

Module markdown 

Source
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§

SourceSpan
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 against links rather than the default scheme list.
scan_delims
Locate the markdown delimiters in src that will actually be consumed, reporting ranges in the source.
scheme_allowed
Whether a [label](url) link may point at url under the default scheme list.
split_blocks
Split a message body into block-level pieces.