Skip to content

Commit 1c9bda1

Browse files
committed
fix: Only log "Markdown anchors feature enabled" once
Issue-44: #44
1 parent 4f896a5 commit 1c9bda1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/mkdocs_autorefs/references.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import logging
66
import re
77
import warnings
8+
from functools import lru_cache
89
from html import escape, unescape
910
from html.parser import HTMLParser
1011
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Match
@@ -385,6 +386,11 @@ def flush(self, alias_to: str | None = None) -> None:
385386
self.anchors.clear()
386387

387388

389+
@lru_cache
390+
def _log_enabling_markdown_anchors() -> None:
391+
log.debug("Enabling Markdown anchors feature")
392+
393+
388394
class AutorefsExtension(Extension):
389395
"""Markdown extension that transforms unresolved references into auto-references.
390396
@@ -424,7 +430,7 @@ def extendMarkdown(self, md: Markdown) -> None: # noqa: N802 (casing: parent me
424430
priority=168, # Right after markdown.inlinepatterns.ReferenceInlineProcessor
425431
)
426432
if self.plugin is not None and self.plugin.scan_toc and "attr_list" in md.treeprocessors:
427-
log.debug("Enabling Markdown anchors feature")
433+
_log_enabling_markdown_anchors()
428434
md.treeprocessors.register(
429435
AnchorScannerTreeProcessor(self.plugin, md),
430436
AnchorScannerTreeProcessor.name,

0 commit comments

Comments
 (0)