Expand description
Filtered line iteration for markdown linting
This module provides a zero-cost abstraction for iterating over markdown lines while automatically filtering out non-content regions like front matter, code blocks, and HTML blocks. This ensures rules only process actual markdown content.
§Architecture
The filtered iterator approach centralizes the logic of what content should be processed by rules, eliminating error-prone manual checks in each rule implementation.
§Examples
use rumdl_lib::lint_context::LintContext;
use rumdl_lib::filtered_lines::FilteredLinesExt;
let content = "---\nurl: http://example.com\n---\n\n# Title\n\nContent";
let ctx = LintContext::new(content, rumdl_lib::config::MarkdownFlavor::Standard, None);
// Simple: get all content lines (skips front matter by default)
for line in ctx.content_lines() {
println!("Line {}: {}", line.line_num, line.content);
}
// Advanced: custom filter configuration
for line in ctx.filtered_lines()
.skip_code_blocks()
.skip_front_matter()
.skip_html_blocks() {
println!("Line {}: {}", line.line_num, line.content);
}Structs§
- Filtered
Line - A single line from a filtered iteration, with guaranteed 1-indexed line numbers
- Filtered
Lines Builder - Builder type that allows chaining filter configuration and converting to an iterator
- Filtered
Lines Iter - Iterator that yields filtered lines based on configuration
- Line
Filter Config - Configuration for filtering lines during iteration
Traits§
- Filtered
Lines Ext - Extension trait that adds filtered iteration methods to
LintContext