Expand description
Inline code spans: the one pattern in the tool that cannot be a regex here.
_SUB_CODE_SPAN is (`+)(?:(?!\1).)*\1, which needs a backreference and a
negative lookahead. The regex crate excludes both by design, so this is
hand-written whatever else the port decides — and it is an approximation of
CommonMark that is reproduced rather than corrected. A real CommonMark span
closes on a run of exactly the opener’s length; this closes on the first
position carrying that many or more, so `a``` is two spans where a
renderer sees one. The corpus pins the approximation. Correcting it here
would make the two implementations disagree with each other, which is the
only thing this port is not allowed to do.
Every expected value in the tests below came from running the Python.
Structs§
- Code
Spans - Iterator over the byte ranges
_SUB_CODE_SPANwould replace.
Functions§
- code_
spans - Every inline code span in
body, as byte ranges. - contains_
unmasked_ pipe '|' in _masked_code_spans(body), without building the mask.- mask_
code_ spans _masked_code_spans: every span blanked to spaces, same length out as in.