Skip to content

feat: refactor anchor handling to pre-scan approach - #28

Merged
geopanther merged 1 commit into
mainfrom
feature/anchor-refactor
May 8, 2026
Merged

feat: refactor anchor handling to pre-scan approach#28
geopanther merged 1 commit into
mainfrom
feature/anchor-refactor

Conversation

@geopanther

Copy link
Copy Markdown
Owner

Refactor anchor processing from post-processing HTML rewriting to a pre-scan approach that builds anchor maps from Markdown before rendering.

Changes

  • Rewrite anchor.py: replace post-processing functions with pre-scan functions
  • Build anchor map from Markdown headings before rendering
  • Inject anchor macros during rendering via ConfluenceRenderer
  • Rewrite fragment-only links during rendering
  • Update document.py with convert_anchors parameter
  • Remove post-processing call from main.py
  • Rewrite all anchor tests for new approach

Testing

  • 133 tests passing

Pre-scan raw markdown for headings before rendering to build a complete
GFM-slug to Confluence-anchor map. The renderer now injects anchor macros
during heading() and rewrites fragment links during link(), eliminating
the post-processing regex pass over rendered HTML.

- Replace anchor.py with pre-scan functions (build_anchor_map_from_markdown)
- Add anchor_map parameter to ConfluenceRenderer
- Remove rewrite_page_anchors() post-processing call from __main__.py
- Pass convert_anchors flag through document API chain
- Update tests for new pre-scan approach
@geopanther
geopanther force-pushed the feature/anchor-refactor branch from 2e249f0 to 4ac273b Compare May 8, 2026 11:51
@geopanther
geopanther merged commit 3eda456 into main May 8, 2026
5 checks passed
@geopanther
geopanther deleted the feature/anchor-refactor branch May 13, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant