pub fn try_parse_emphasis(
text: &str,
pos: usize,
end: usize,
config: &ParserOptions,
builder: &mut GreenNodeBuilder<'_>,
) -> Option<(usize, usize)>Expand description
Try to parse emphasis starting at the given position.
This is the entry point for recursive emphasis parsing, equivalent to
Pandoc’s enclosure function.
Returns Some((bytes_consumed, delim_count)) if emphasis was successfully parsed, or None if the delimiter should be treated as literal text. When returning None, the delim_count tells the caller how many delimiter characters to skip (to avoid re-parsing parts of a failed delimiter run).
§Arguments
text- The full text being parsedpos- Current position in text (where the delimiter starts)end- End boundary (don’t search for closers beyond this)config- Configurationbuilder- CST builder
Algorithm:
- Count opening delimiters
- Check if followed by whitespace (if so, return None)
- Dispatch to parse_one/two/three based on count
- Those functions parse content and look for matching closer (within bounds)
- If closer found, emit node and return bytes consumed
- If not found, return None with delimiter count (caller skips entire run)