pub struct MD053LinkImageReferenceDefinitions { /* private fields */ }
Expand description
Rule MD053: Link and image reference definitions should be used
See docs/md053.md for full documentation, configuration, and examples.
This rule is triggered when a link or image reference definition is declared but not used anywhere in the document. Unused reference definitions can create confusion and clutter.
§Supported Reference Formats
This rule handles the following reference formats:
- Full reference links/images:
[text][reference]
or![text][reference]
- Collapsed reference links/images:
[text][]
or![text][]
- Shortcut reference links:
[reference]
(must be defined elsewhere) - Reference definitions:
[reference]: URL "Optional Title"
- Multi-line reference definitions:
[reference]: URL "Optional title continued on next line"
§Configuration Options
The rule supports the following configuration options:
MD053:
ignored_definitions: [] # List of reference definitions to ignore (never report as unused)
§Performance Optimizations
This rule implements various performance optimizations for handling large documents:
- Caching: The rule caches parsed definitions and references based on content hashing
- Efficient Reference Matching: Uses HashMaps for O(1) lookups of definitions
- Smart Code Block Handling: Efficiently skips references inside code blocks/spans
- Lazy Evaluation: Only processes necessary portions of the document
§Edge Cases Handled
- Case insensitivity: References are matched case-insensitively
- Escaped characters: Properly processes escaped characters in references
- Unicode support: Handles non-ASCII characters in references and URLs
- Code blocks: Ignores references inside code blocks and spans
- Special characters: Properly handles references with special characters
§Fix Behavior
This rule does not provide automatic fixes. Unused references must be manually reviewed and removed, as they may be intentionally kept for future use or as templates.
Implementations§
Source§impl MD053LinkImageReferenceDefinitions
impl MD053LinkImageReferenceDefinitions
Sourcepub fn from_config_struct(config: MD053Config) -> Self
pub fn from_config_struct(config: MD053Config) -> Self
Create a new instance with the given configuration
Trait Implementations§
Source§impl Clone for MD053LinkImageReferenceDefinitions
impl Clone for MD053LinkImageReferenceDefinitions
Source§fn clone(&self) -> MD053LinkImageReferenceDefinitions
fn clone(&self) -> MD053LinkImageReferenceDefinitions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Rule for MD053LinkImageReferenceDefinitions
impl Rule for MD053LinkImageReferenceDefinitions
Source§fn check(&self, ctx: &LintContext<'_>) -> LintResult
fn check(&self, ctx: &LintContext<'_>) -> LintResult
Check the content for unused and duplicate link/image reference definitions.
This implementation uses caching for improved performance on large documents.
Source§fn fix(&self, ctx: &LintContext<'_>) -> Result<String, LintError>
fn fix(&self, ctx: &LintContext<'_>) -> Result<String, LintError>
MD053 does not provide automatic fixes
Source§fn should_skip(&self, ctx: &LintContext<'_>) -> bool
fn should_skip(&self, ctx: &LintContext<'_>) -> bool
Check if this rule should be skipped for performance
fn name(&self) -> &'static str
fn description(&self) -> &'static str
fn as_any(&self) -> &dyn Any
Source§fn default_config_section(&self) -> Option<(String, Value)>
fn default_config_section(&self) -> Option<(String, Value)>
impl Rule for ...
block,
not just the inherent impl.Source§fn from_config(config: &Config) -> Box<dyn Rule>where
Self: Sized,
fn from_config(config: &Config) -> Box<dyn Rule>where
Self: Sized,
Source§fn check_with_structure(
&self,
ctx: &LintContext<'_>,
_structure: &DocumentStructure,
) -> LintResult
fn check_with_structure( &self, ctx: &LintContext<'_>, _structure: &DocumentStructure, ) -> LintResult
Source§fn check_with_ast(
&self,
ctx: &LintContext<'_>,
_ast: &MarkdownAst,
) -> LintResult
fn check_with_ast( &self, ctx: &LintContext<'_>, _ast: &MarkdownAst, ) -> LintResult
Source§fn check_with_structure_and_ast(
&self,
ctx: &LintContext<'_>,
_structure: &DocumentStructure,
_ast: &MarkdownAst,
) -> LintResult
fn check_with_structure_and_ast( &self, ctx: &LintContext<'_>, _structure: &DocumentStructure, _ast: &MarkdownAst, ) -> LintResult
Source§fn category(&self) -> RuleCategory
fn category(&self) -> RuleCategory
Source§fn uses_document_structure(&self) -> bool
fn uses_document_structure(&self) -> bool
fn as_maybe_document_structure(&self) -> Option<&dyn MaybeDocumentStructure>
fn as_maybe_ast(&self) -> Option<&dyn MaybeAst>
Source§fn config_aliases(&self) -> Option<HashMap<String, String>>
fn config_aliases(&self) -> Option<HashMap<String, String>>
Source§fn fix_capability(&self) -> FixCapability
fn fix_capability(&self) -> FixCapability
Auto Trait Implementations§
impl Freeze for MD053LinkImageReferenceDefinitions
impl RefUnwindSafe for MD053LinkImageReferenceDefinitions
impl Send for MD053LinkImageReferenceDefinitions
impl Sync for MD053LinkImageReferenceDefinitions
impl Unpin for MD053LinkImageReferenceDefinitions
impl UnwindSafe for MD053LinkImageReferenceDefinitions
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