From 036b825c7994b2586564e8707fbc0b3627c29569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Tue, 14 May 2024 14:13:53 +0200 Subject: [PATCH] refactor: Attach name to processors for easier retrieval --- src/mkdocs_autorefs/references.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mkdocs_autorefs/references.py b/src/mkdocs_autorefs/references.py index 59999c0..2fe1d6a 100644 --- a/src/mkdocs_autorefs/references.py +++ b/src/mkdocs_autorefs/references.py @@ -43,6 +43,8 @@ class AutoRefInlineProcessor(ReferenceInlineProcessor): """A Markdown extension.""" + name: str = "mkdocs-autorefs" + def __init__(self, *args: Any, **kwargs: Any) -> None: # noqa: D107 super().__init__(REFERENCE_RE, *args, **kwargs) @@ -224,6 +226,7 @@ def fix_refs(html: str, url_mapper: Callable[[str], str]) -> tuple[str, list[str class AnchorScannerTreeProcessor(Treeprocessor): """Tree processor to scan and register HTML anchors.""" + name: str = "mkdocs-autorefs-anchors-scanner" _htags: ClassVar[set[str]] = {"h1", "h2", "h3", "h4", "h5", "h6"} def __init__(self, plugin: AutorefsPlugin, md: Markdown | None = None) -> None: @@ -317,13 +320,13 @@ def extendMarkdown(self, md: Markdown) -> None: # noqa: N802 (casing: parent me """ md.inlinePatterns.register( AutoRefInlineProcessor(md), - "mkdocs-autorefs", + AutoRefInlineProcessor.name, priority=168, # Right after markdown.inlinepatterns.ReferenceInlineProcessor ) if self.plugin is not None and self.plugin.scan_toc and "attr_list" in md.treeprocessors: log.debug("Enabling Markdown anchors feature") md.treeprocessors.register( AnchorScannerTreeProcessor(self.plugin, md), - "mkdocs-autorefs-anchors-scanner", + AnchorScannerTreeProcessor.name, priority=0, )