Skip to main content

Module support

Module support 

Source
Expand description

Internal parser support helpers.

Structsยง

ParsedLabel ๐Ÿ”’
RawListLine ๐Ÿ”’
One marker line captured during list collection. Not user-facing โ€“ the public AST uses crate::ListItem after nesting is resolved.

Functionsยง

find_byte ๐Ÿ”’
is_escaped ๐Ÿ”’
Whether the byte at pos is escaped by an odd-length run of \ immediately before it (bounded below by start). Backslashes pair up (\\ is a hard break, not an escape), so only an odd count escapes the following byte. The label scanners use this so a \< opens literal < text instead of a label.
list_marker_at ๐Ÿ”’
If the line that starts at pos opens with a list marker, return Some((indent, ordered, content_start)). indent counts the leading ASCII spaces before the marker; ordered is true for \d+\. and false for - ; content_start is the byte offset of the first byte after the marker plus its trailing whitespace run. Tabs are not recognised as either indent or post-marker whitespace in MVP 0.
locate_label ๐Ÿ”’
Locate the first <label> token in src[start..end], returning the parsed label and the byte offset just past its >. Unlike strip_trailing_label this finds a label anywhere in the range, so the heading parser can detect a label that is not the trailing element (e.g. = Title <id> trailing) and flag it (MOS0048) instead of silently swallowing it into the text.
next_char_boundary ๐Ÿ”’
Return the byte offset of the next character boundary at or after from + 1. Used to step over a single Unicode scalar value when accumulating string literal contents.
normalize_raw_text ๐Ÿ”’
scan_label_chars ๐Ÿ”’
Returns the byte offset just past the longest label-identifier run that starts at from in bytes. Empty (caller should detect via id_end == from) if the first byte is not a valid identifier char.
skip_set_ws ๐Ÿ”’
Skip ASCII whitespace (space, tab, CR, LF) inside a #set body.
skip_to_comma ๐Ÿ”’
Advance to the next , or end-of-body, used for error recovery inside directive argument parsing.
strip_leading_label ๐Ÿ”’
If the substring src[start..end] begins with optional ASCII whitespace followed by <label>, return (label_body_start, Some(id)) where label_body_start is the offset just past the closing > (with any trailing whitespace also consumed). Otherwise return (start, None).
strip_trailing_label ๐Ÿ”’
If the substring src[start..end] ends with <label> (after any trailing ASCII whitespace), return (text_end, Some(id)) where text_end is the offset of the first byte to exclude from the preceding text โ€“ trailing whitespace before the label is also trimmed. Otherwise return (end, None).