pub struct LintContext<'a> {Show 15 fields
pub content: &'a str,
pub line_offsets: Vec<usize>,
pub code_blocks: Vec<(usize, usize)>,
pub lines: Vec<LineInfo>,
pub links: Vec<ParsedLink<'a>>,
pub images: Vec<ParsedImage<'a>>,
pub broken_links: Vec<BrokenLinkInfo>,
pub footnote_refs: Vec<FootnoteRef>,
pub reference_defs: Vec<ReferenceDef>,
pub list_blocks: Vec<ListBlock>,
pub char_frequency: CharFrequency,
pub table_blocks: Vec<TableBlock>,
pub line_index: LineIndex<'a>,
pub flavor: MarkdownFlavor,
pub source_file: Option<PathBuf>,
/* private fields */
}Fields§
§content: &'a str§line_offsets: Vec<usize>§code_blocks: Vec<(usize, usize)>§lines: Vec<LineInfo>§links: Vec<ParsedLink<'a>>§images: Vec<ParsedImage<'a>>§broken_links: Vec<BrokenLinkInfo>§footnote_refs: Vec<FootnoteRef>§reference_defs: Vec<ReferenceDef>§list_blocks: Vec<ListBlock>§char_frequency: CharFrequency§table_blocks: Vec<TableBlock>§line_index: LineIndex<'a>§flavor: MarkdownFlavor§source_file: Option<PathBuf>Implementations§
Source§impl<'a> LintContext<'a>
impl<'a> LintContext<'a>
pub fn new( content: &'a str, flavor: MarkdownFlavor, source_file: Option<PathBuf>, ) -> Self
Sourcepub fn code_spans(&self) -> Arc<Vec<CodeSpan>>
pub fn code_spans(&self) -> Arc<Vec<CodeSpan>>
Get code spans - computed lazily on first access
Sourcepub fn html_comment_ranges(&self) -> &[ByteRange]
pub fn html_comment_ranges(&self) -> &[ByteRange]
Get HTML comment ranges - pre-computed during LintContext construction
Get HTML tags - computed lazily on first access
Sourcepub fn emphasis_spans(&self) -> Arc<Vec<EmphasisSpan>>
pub fn emphasis_spans(&self) -> Arc<Vec<EmphasisSpan>>
Get emphasis spans - computed lazily on first access
Sourcepub fn table_rows(&self) -> Arc<Vec<TableRow>>
pub fn table_rows(&self) -> Arc<Vec<TableRow>>
Get table rows - computed lazily on first access
Sourcepub fn offset_to_line_col(&self, offset: usize) -> (usize, usize)
pub fn offset_to_line_col(&self, offset: usize) -> (usize, usize)
Map a byte offset to (line, column)
Sourcepub fn is_in_code_block_or_span(&self, pos: usize) -> bool
pub fn is_in_code_block_or_span(&self, pos: usize) -> bool
Check if a position is within a code block or code span
Sourcepub fn line_info(&self, line_num: usize) -> Option<&LineInfo>
pub fn line_info(&self, line_num: usize) -> Option<&LineInfo>
Get line information by line number (1-indexed)
Sourcepub fn line_to_byte_offset(&self, line_num: usize) -> Option<usize>
pub fn line_to_byte_offset(&self, line_num: usize) -> Option<usize>
Get byte offset for a line number (1-indexed)
Sourcepub fn get_reference_url(&self, ref_id: &str) -> Option<&str>
pub fn get_reference_url(&self, ref_id: &str) -> Option<&str>
Get URL for a reference link/image by its ID
Sourcepub fn is_in_list_block(&self, line_num: usize) -> bool
pub fn is_in_list_block(&self, line_num: usize) -> bool
Check if a line is part of a list block
Sourcepub fn list_block_for_line(&self, line_num: usize) -> Option<&ListBlock>
pub fn list_block_for_line(&self, line_num: usize) -> Option<&ListBlock>
Get the list block containing a specific line
Sourcepub fn is_in_code_block(&self, line_num: usize) -> bool
pub fn is_in_code_block(&self, line_num: usize) -> bool
Check if a line is within a code block
Sourcepub fn is_in_front_matter(&self, line_num: usize) -> bool
pub fn is_in_front_matter(&self, line_num: usize) -> bool
Check if a line is within front matter
Sourcepub fn is_in_html_block(&self, line_num: usize) -> bool
pub fn is_in_html_block(&self, line_num: usize) -> bool
Check if a line is within an HTML block
Sourcepub fn is_in_code_span(&self, line_num: usize, col: usize) -> bool
pub fn is_in_code_span(&self, line_num: usize, col: usize) -> bool
Check if a line and column is within a code span
Sourcepub fn is_byte_offset_in_code_span(&self, byte_offset: usize) -> bool
pub fn is_byte_offset_in_code_span(&self, byte_offset: usize) -> bool
Check if a byte offset is within a code span
Sourcepub fn is_in_reference_def(&self, byte_pos: usize) -> bool
pub fn is_in_reference_def(&self, byte_pos: usize) -> bool
Check if a byte position is within a reference definition This is much faster than scanning the content with regex for each check (O(1) vs O(n))
Sourcepub fn is_in_html_comment(&self, byte_pos: usize) -> bool
pub fn is_in_html_comment(&self, byte_pos: usize) -> bool
Check if a byte position is within an HTML comment This is much faster than scanning the content with regex for each check (O(k) vs O(n)) where k is the number of HTML comments (typically very small)
Sourcepub fn is_in_html_tag(&self, byte_pos: usize) -> bool
pub fn is_in_html_tag(&self, byte_pos: usize) -> bool
Check if a byte position is within an HTML tag (including multiline tags) Uses the pre-parsed html_tags which correctly handles tags spanning multiple lines
Sourcepub fn is_in_jinja_range(&self, byte_pos: usize) -> bool
pub fn is_in_jinja_range(&self, byte_pos: usize) -> bool
Check if a byte position is within a Jinja template ({{ }} or {% %})
Sourcepub fn is_in_link_title(&self, byte_pos: usize) -> bool
pub fn is_in_link_title(&self, byte_pos: usize) -> bool
Check if a byte position is within a link reference definition title
Sourcepub fn has_char(&self, ch: char) -> bool
pub fn has_char(&self, ch: char) -> bool
Check if content has any instances of a specific character (fast)
Sourcepub fn char_count(&self, ch: char) -> usize
pub fn char_count(&self, ch: char) -> usize
Get count of a specific character (fast)
Sourcepub fn likely_has_headings(&self) -> bool
pub fn likely_has_headings(&self) -> bool
Check if content likely contains headings (fast)
Sourcepub fn likely_has_lists(&self) -> bool
pub fn likely_has_lists(&self) -> bool
Check if content likely contains lists (fast)
Sourcepub fn likely_has_emphasis(&self) -> bool
pub fn likely_has_emphasis(&self) -> bool
Check if content likely contains emphasis (fast)
Sourcepub fn likely_has_tables(&self) -> bool
pub fn likely_has_tables(&self) -> bool
Check if content likely contains tables (fast)
Sourcepub fn likely_has_blockquotes(&self) -> bool
pub fn likely_has_blockquotes(&self) -> bool
Check if content likely contains blockquotes (fast)
Sourcepub fn likely_has_code(&self) -> bool
pub fn likely_has_code(&self) -> bool
Check if content likely contains code (fast)
Sourcepub fn likely_has_links_or_images(&self) -> bool
pub fn likely_has_links_or_images(&self) -> bool
Check if content likely contains links or images (fast)
Sourcepub fn likely_has_html(&self) -> bool
pub fn likely_has_html(&self) -> bool
Check if content likely contains HTML (fast)
Get HTML tags on a specific line
Sourcepub fn emphasis_spans_on_line(&self, line_num: usize) -> Vec<EmphasisSpan>
pub fn emphasis_spans_on_line(&self, line_num: usize) -> Vec<EmphasisSpan>
Get emphasis spans on a specific line
Sourcepub fn table_rows_on_line(&self, line_num: usize) -> Vec<TableRow>
pub fn table_rows_on_line(&self, line_num: usize) -> Vec<TableRow>
Get table rows on a specific line
Sourcepub fn bare_urls_on_line(&self, line_num: usize) -> Vec<BareUrl>
pub fn bare_urls_on_line(&self, line_num: usize) -> Vec<BareUrl>
Get bare URLs on a specific line
Sourcepub fn valid_headings(&self) -> ValidHeadingsIter<'_> ⓘ
pub fn valid_headings(&self) -> ValidHeadingsIter<'_> ⓘ
Get an iterator over valid CommonMark headings
This iterator filters out malformed headings like #NoSpace (hashtag-like patterns)
that should be flagged by MD018 but should not be processed by other heading rules.
§Examples
use rumdl_lib::lint_context::LintContext;
use rumdl_lib::config::MarkdownFlavor;
let content = "# Valid Heading\n#NoSpace\n## Another Valid";
let ctx = LintContext::new(content, MarkdownFlavor::Standard, None);
for heading in ctx.valid_headings() {
println!("Line {}: {} (level {})", heading.line_num, heading.heading.text, heading.heading.level);
}
// Only prints valid headings, skips `#NoSpace`Sourcepub fn has_valid_headings(&self) -> bool
pub fn has_valid_headings(&self) -> bool
Check if the document contains any valid CommonMark headings
Returns true if there is at least one heading with proper space after #.
Trait Implementations§
Source§impl<'a> FilteredLinesExt for LintContext<'a>
impl<'a> FilteredLinesExt for LintContext<'a>
Source§fn filtered_lines(&self) -> FilteredLinesBuilder<'_>
fn filtered_lines(&self) -> FilteredLinesBuilder<'_>
Source§fn content_lines(&self) -> FilteredLinesIter<'_> ⓘ
fn content_lines(&self) -> FilteredLinesIter<'_> ⓘ
Auto Trait Implementations§
impl<'a> !Freeze for LintContext<'a>
impl<'a> RefUnwindSafe for LintContext<'a>
impl<'a> Send for LintContext<'a>
impl<'a> Sync for LintContext<'a>
impl<'a> Unpin for LintContext<'a>
impl<'a> UnwindSafe for LintContext<'a>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more