Skip to content

Commit 3ac4797

Browse files
committed
refactor: Ignore Markdown anchors when setting backlink metadata on autorefs
The reason is that they don't appear in the table of contents, and therefore their URLs aren't collected for backlinking. Plus, they don't have titles so we'd have to record titles of headings above them. This is far from impossible, we might simply do that later.
1 parent ca6461e commit 3ac4797

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

src/mkdocs_autorefs/_internal/backlinks.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ def run(self, root: Element) -> None:
7878

7979
def _enhance_autorefs(self, parent: Element) -> None:
8080
for el in parent:
81-
if el.tag == "a": # Markdown anchor.
82-
if not (el.text or el.get("href") or (el.tail and el.tail.strip())) and (anchor_id := el.get("id")):
83-
self._last_heading_id = anchor_id
84-
elif el.tag in self._htags: # Heading.
81+
if el.tag in self._htags:
8582
self._last_heading_id = el.get("id")
8683
elif el.tag == "autoref":
8784
if "backlink-type" not in el.attrib:

0 commit comments

Comments
 (0)