diff --git a/src/mkdocs_autorefs/plugin.py b/src/mkdocs_autorefs/plugin.py
index 5eca316..ba333e8 100644
--- a/src/mkdocs_autorefs/plugin.py
+++ b/src/mkdocs_autorefs/plugin.py
@@ -15,9 +15,12 @@
import contextlib
import functools
import logging
-from typing import TYPE_CHECKING, Any, Callable, Sequence
+import re
+from typing import Callable, Dict, Optional, Sequence
from urllib.parse import urlsplit
+from mkdocs.config import Config
+from mkdocs.config.config_options import Type
from mkdocs.plugins import BasePlugin
from mkdocs_autorefs.references import AutorefsExtension, fix_refs, relative_url
@@ -49,8 +52,12 @@ class AutorefsPlugin(BasePlugin):
for more information about its plugin system.
"""
+ config = (
+ ("scan_html_tags", Type(bool, default=False))
+ )
+
scan_toc: bool = True
- current_page: str | None = None
+ current_page: Optional[str] = None
def __init__(self) -> None:
"""Initialize the object."""
@@ -170,6 +177,12 @@ def on_page_content(self, html: str, page: Page, **kwargs: Any) -> str: # noqa:
log.debug(f"Mapping identifiers to URLs for page {page.file.src_path}")
for item in page.toc.items:
self.map_urls(page.url, item)
+
+ if self.config["scan_html_tags"]:
+ # Matches any html anchors with the id property (e.g. )
+ for match in re.findall(r"""""", html):
+ self.register_anchor(page.url, match)
+
return html
def map_urls(self, base_url: str, anchor: AnchorLink) -> None: