Skip to content

Commit

Permalink
translator: replace spaces with dashes when resolving title anchors
Browse files Browse the repository at this point in the history
When attempting to determine the anchor target for a named title entry,
replace any spaces found in a named entry to ensure it can map to an
appropriate anchor value (since anchors have no spaces). This should
ensure the sanity check for a target lookup help finds the title has a
valid target to ensure the anchor is created.

Signed-off-by: James Knight <[email protected]>
  • Loading branch information
jdknight committed Nov 5, 2024
1 parent 6c2d102 commit f903ecf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sphinxcontrib/confluencebuilder/storage/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ def visit_title(self, node):
# repsective document name) which helps allow `ac:link` macros
# properly link when coming from v1 or v2 editor pages.
if self.v2 and 'names' in node.parent:
for anchor in node.parent['names']:
for name in node.parent['names']:
anchor = name.replace(' ', '-')
target_name = f'{docname}/#{anchor}'
target = self.state.target(target_name)
if target and target not in new_targets:
Expand Down

0 comments on commit f903ecf

Please sign in to comment.