pub struct FileIndex {
pub headings: Vec<HeadingIndex>,
pub reference_links: Vec<ReferenceLinkIndex>,
pub cross_file_links: Vec<CrossFileLinkIndex>,
pub defined_references: HashSet<String>,
pub content_hash: String,
pub file_disabled_rules: HashSet<String>,
pub line_disabled_rules: HashMap<usize, HashSet<String>>,
/* private fields */
}Expand description
Index data extracted from a single file
Fields§
§headings: Vec<HeadingIndex>Headings in this file with their anchors
reference_links: Vec<ReferenceLinkIndex>Reference links in this file (for cross-file analysis)
cross_file_links: Vec<CrossFileLinkIndex>Cross-file links in this file (for MD051 cross-file validation)
defined_references: HashSet<String>Defined reference IDs (e.g., from [ref]: url definitions) Used to filter out reference links that have explicit definitions
content_hash: StringContent hash for change detection
file_disabled_rules: HashSet<String>Rules disabled for the entire file (from inline comments) Used by cross-file rules to respect inline disable directives
line_disabled_rules: HashMap<usize, HashSet<String>>Rules disabled at specific lines (line number -> set of rule names) Merges both persistent disables and line-specific disables
Implementations§
Source§impl FileIndex
impl FileIndex
Sourcepub fn add_heading(&mut self, heading: HeadingIndex)
pub fn add_heading(&mut self, heading: HeadingIndex)
Add a heading to the index
Also updates the anchor lookup map for O(1) anchor queries
Sourcepub fn has_anchor(&self, anchor: &str) -> bool
pub fn has_anchor(&self, anchor: &str) -> bool
Check if an anchor exists in this file (O(1) lookup)
Returns true if the anchor matches any of:
- Auto-generated heading anchors
- Custom heading anchors (from {#id} syntax on headings)
- HTML anchors (from or
) - Attribute anchors (from { #id } syntax on non-heading elements)
Matching is case-insensitive. URL-encoded anchors (e.g., CJK characters
like %E6%97%A5%E6%9C%AC%E8%AA%9E for 日本語) are decoded before matching.
Sourcepub fn add_html_anchor(&mut self, anchor: String)
pub fn add_html_anchor(&mut self, anchor: String)
Add an HTML anchor (from or
Sourcepub fn add_attribute_anchor(&mut self, anchor: String)
pub fn add_attribute_anchor(&mut self, anchor: String)
Add an attribute anchor (from { #id } syntax on non-heading elements)
Sourcepub fn get_heading_by_anchor(&self, anchor: &str) -> Option<&HeadingIndex>
pub fn get_heading_by_anchor(&self, anchor: &str) -> Option<&HeadingIndex>
Get the heading index for an anchor (O(1) lookup)
Returns the index into self.headings if found.
Sourcepub fn add_reference_link(&mut self, link: ReferenceLinkIndex)
pub fn add_reference_link(&mut self, link: ReferenceLinkIndex)
Add a reference link to the index
Sourcepub fn is_rule_disabled_at_line(&self, rule_name: &str, line: usize) -> bool
pub fn is_rule_disabled_at_line(&self, rule_name: &str, line: usize) -> bool
Check if a rule is disabled at a specific line
Used by cross-file rules to respect inline disable directives. Checks both file-wide disables and line-specific disables.
Sourcepub fn add_cross_file_link(&mut self, link: CrossFileLinkIndex)
pub fn add_cross_file_link(&mut self, link: CrossFileLinkIndex)
Add a cross-file link to the index (deduplicates by target_path, fragment, line)
Sourcepub fn add_defined_reference(&mut self, ref_id: String)
pub fn add_defined_reference(&mut self, ref_id: String)
Add a defined reference ID (e.g., from [ref]: url)
Sourcepub fn has_defined_reference(&self, ref_id: &str) -> bool
pub fn has_defined_reference(&self, ref_id: &str) -> bool
Check if a reference ID has an explicit definition
Sourcepub fn hash_matches(&self, hash: &str) -> bool
pub fn hash_matches(&self, hash: &str) -> bool
Check if the content hash matches
Sourcepub fn heading_count(&self) -> usize
pub fn heading_count(&self) -> usize
Get the number of headings
Sourcepub fn reference_link_count(&self) -> usize
pub fn reference_link_count(&self) -> usize
Get the number of reference links
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FileIndex
impl<'de> Deserialize<'de> for FileIndex
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for FileIndex
impl RefUnwindSafe for FileIndex
impl Send for FileIndex
impl Sync for FileIndex
impl Unpin for FileIndex
impl UnwindSafe for FileIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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