feat: add linkable heading anchors to PSF pages by nagasrisai · Pull Request #2966 · python/pythondotorg
added 4 commits
March 18, 2026 17:45Adds a custom template filter that post-processes rendered page HTML to inject id attributes and pilcrow self-link anchors into h2-h4 headings. Duplicate slugs get a -N suffix to prevent id collisions. Headings that already carry an id are left untouched. Part of python#2349
Loads the new page_tags library and pipes page content through the add_heading_anchors filter so that every h2-h4 in a PSF page (including the board resolutions listing) gets a stable id attribute and a pilcrow anchor link for direct linking. Part of python#2349
Two bugs fixed: 1. The regex only matched h2-h4, so RST-generated pages like the board resolutions page (which use h1 section headings) received no anchors. Extended to h1-h4. 2. Headings that already carry an id attribute (docutils/RST injects these automatically on every section heading) were silently skipped. The filter now reuses the existing id and injects the pilcrow link using it, which is exactly what is needed for RST-sourced pages like the bylaws and resolutions pages. Also added idempotency guard so running the filter twice is safe.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters