Skip to content

Commit

Permalink
fix: Only log "Markdown anchors feature enabled" once
Browse files Browse the repository at this point in the history
Issue-44: #44
  • Loading branch information
pawamoy committed Aug 20, 2024
1 parent 4f896a5 commit 1c9bda1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/mkdocs_autorefs/references.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import re
import warnings
from functools import lru_cache
from html import escape, unescape
from html.parser import HTMLParser
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Match
Expand Down Expand Up @@ -385,6 +386,11 @@ def flush(self, alias_to: str | None = None) -> None:
self.anchors.clear()


@lru_cache
def _log_enabling_markdown_anchors() -> None:
log.debug("Enabling Markdown anchors feature")


class AutorefsExtension(Extension):
"""Markdown extension that transforms unresolved references into auto-references.
Expand Down Expand Up @@ -424,7 +430,7 @@ def extendMarkdown(self, md: Markdown) -> None: # noqa: N802 (casing: parent me
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")
_log_enabling_markdown_anchors()
md.treeprocessors.register(
AnchorScannerTreeProcessor(self.plugin, md),
AnchorScannerTreeProcessor.name,
Expand Down

0 comments on commit 1c9bda1

Please sign in to comment.