pub fn code_spans(line: &str) -> Vec<(usize, usize)>Expand description
The byte ranges of line’s matched inline code spans, in order.
The CommonMark rule, in one place: a span opens with a run of n backticks
and closes with the next run of exactly n; an opening run with no matching
close is literal text and yields no span. A backslash-escaped backtick is
literal and opens nothing — without that, \` paired with a later real
opener and swallowed everything between them, which hid a table column from
rto_spec::fmt and would hide a [[…]] link or a @rto: annotation from
the scanners that read this. The rule is asymmetric: escapes do not work
inside a code span, so a backslash before the closing run is content and
the run still closes.
Separate from strip_code_spans because removing a span and knowing where
one is are different questions, and rto_spec::fmt needs the second — a
table row’s | inside a code span is content rather than a column boundary.
It had its own backtick scanner until #790 found that it entered code mode on
an unmatched run and hid the rest of the row, which is exactly the case this
rule exists to get right.