Skip to main content

Module code_span

Module code_span 

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

CodeSpans
Iterator over the byte ranges _SUB_CODE_SPAN would 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.