pub struct MarkdownParser<'a> { /* private fields */ }Implementations§
Source§impl<'a> MarkdownParser<'a>
impl<'a> MarkdownParser<'a>
pub fn new(content: &'a str) -> Self
pub fn content(&self) -> &'a str
pub fn lines(&self) -> &[&'a str]
pub fn line_count(&self) -> usize
pub fn get_line(&self, line_num: usize) -> Option<&'a str>
pub fn parse(&self) -> impl Iterator<Item = Event<'a>> + 'a
pub fn parse_with_offsets( &self, ) -> impl Iterator<Item = (Event<'a>, Range<usize>)>
pub fn offset_to_line(&self, offset: usize) -> usize
pub fn offset_to_position(&self, offset: usize) -> (usize, usize)
Sourcepub fn get_code_line_numbers(&self) -> HashSet<usize>
pub fn get_code_line_numbers(&self) -> HashSet<usize>
Returns a set of line numbers that are inside code blocks or inline code. This is useful for rules that should ignore code content.
Note: For inline code, this marks the entire line as code. For more precise
detection, use get_code_ranges() instead.
Sourcepub fn get_code_block_line_numbers(&self) -> HashSet<usize>
pub fn get_code_block_line_numbers(&self) -> HashSet<usize>
Returns a set of line numbers that are inside code BLOCKS only (not inline code). This is useful for rules that need to check list markers, URLs, etc. that might legitimately appear on lines with inline code. Lines are 1-indexed to match violation reporting.
Sourcepub fn get_code_ranges(&self) -> Vec<Range<usize>>
pub fn get_code_ranges(&self) -> Vec<Range<usize>>
Returns a vector of byte ranges that are inside code (blocks or inline).
This is more precise than get_code_line_numbers() for inline code.
Sourcepub fn line_offset_to_absolute(
&self,
line_num: usize,
byte_offset_in_line: usize,
) -> usize
pub fn line_offset_to_absolute( &self, line_num: usize, byte_offset_in_line: usize, ) -> usize
Converts a byte offset within a line to an absolute byte offset in the content. line_num is 1-indexed, byte_offset_in_line is 0-indexed from start of line.