-
Notifications
You must be signed in to change notification settings - Fork 103
Description
Summary
When using maxdepth: 2 in toctrees, the builder generates cross-page section links using ac:link ac:anchor → ac:structured-macro ac:name="anchor". The storage format is correct on both source and target pages. However, on Confluence Cloud (v2/fabric editor), clicking these links navigates to the correct page but drops the anchor fragment — the browser does not scroll to the referenced section.
Environment
- sphinxcontrib-confluencebuilder: 3.0.0
- Sphinx: 9.0.4
- Python: 3.11.9
- Confluence: Cloud (
.[atlassian.net/wiki/](http://atlassian.net/wiki/)) - Editor: v2 (auto-detected by builder v3.0)
- API mode: v2 (auto-detected)
- No explicit
confluence_editororconfluence_api_modeset
Reproduction
Source document (guide/index.md)
## User Guide Pages
```{toctree}
:maxdepth: 2
models-to-focus
### Target document (`guide/models-to-focus.md`)
```markdown
# Models to Focus
Some intro text.
## Data Source
Models to Focus queries the `trigger_programs_of_concern` table...
## Key Metrics
### Score
A composite battery health score...
Build command
sphinx-build -M confluence docs docs/_build -E -aGenerated storage format
Source page (guide/index) — toctree links
<ac:link ac:anchor="Data-Source">
<ri:page ri:content-title="Models to Focus" />
<ac:link-body>Data Source</ac:link-body>
</ac:link>Target page (guide/models-to-focus) — anchor definitions
<h2><ac:structured-macro ac:name="anchor">
<ac:parameter ac:name="">Data-Source</ac:parameter>
</ac:structured-macro><ac:structured-macro ac:name="anchor">
<ac:parameter ac:name="">ModelstoFocus-Data-Source</ac:parameter>
</ac:structured-macro>Data Source</h2>Both sides match: ac:link ac:anchor="Data-Source" references ac:structured-macro ac:name="anchor" with parameter Data-Source.
Observed behavior
Clicking the "Data Source" link in the toctree navigates to:
https://example.atlassian.net/wiki/spaces/MYSPACE/pages/123456
The anchor fragment (#Data-Source) is not appended; the page loads at the top.
Expected behavior
The link should navigate to:
https://example.atlassian.net/wiki/spaces/MYSPACE/pages/123456/Models+to+Focus#Data-Source
...scrolling to the "Data Source" heading.
Additional context
- Confluence Cloud's v2 editor wraps anchor macros as inline extensions. Inspecting the rendered DOM, the heading's HTML
idattribute becomes[inlineExtension][inlineExtension]Data-Source(because the twoac:structured-macroelements inside the<h2>are serialized as[inlineExtension]tokens). Theac:link ac:anchor="Data-Source"may fail to resolve because the rendered anchor ID doesn't matchData-Source. - Same-page TOC links work. The Confluence-native TOC macro generates URLs with the
[inlineExtension]prefix and correctly scrolls to sections. - Using
maxdepth: 1avoids the issue (no sub-section anchor links generated), but loses section-level detail in navigation. - Not the same as Link to section titles - broken ? #1057 (Data Center v2 anchor formatting, fixed v2.9). Our anchors have no special characters — simple slugs like
Data-Source,Purpose,Key-Metrics. - PR Replace special anchor handling #1129 ("Replace special anchor handling") targets anchors with characters like parentheses and is included in v3.0.0, but does not apply to our simple anchor names.
- A contributor in sphinxcontrib-confluencebuilder v3 Cloud Users Notice #1166 reported a similar symptom ("anchors link to page but not section") which allegedly resolved after republishing. We have republished multiple times (including with
CONFLUENCE_CLOUD_V2_MIGRATION=1) and the issue persists.
Workaround
Set maxdepth: 1 on all toctrees to avoid generating cross-page section links. This prevents broken links but loses section-level navigation from parent pages.