Skip to content

Commit 318791c

Browse files
authored
Merge pull request #1143 from sphinx-contrib/support-backref-updates-in-singleconfluence
correct backref (footnotes/citations) updates in singleconfluence
2 parents ca5ba15 + b58460a commit 318791c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sphinxcontrib/confluencebuilder/singlebuilder.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,21 @@ def _inline_all_toctrees(self, docname, doctree, traversed, uids):
215215
target['ids'] = new_ids
216216

217217
for target in findall(tree, nodes.Element):
218+
# update any reference targets to their new identifier (if any)
218219
refid = target.get('refid')
219220
if refid:
220221
new_refid = updated_refids.get(refid)
221222
if new_refid:
222223
target['refid'] = new_refid
223224

225+
# update any back references to their new identifier (if any)
226+
backrefs = target.get('backrefs')
227+
if backrefs:
228+
for idx, backref in enumerate(backrefs):
229+
new_backref = updated_refids.get(backref)
230+
if new_backref:
231+
backrefs[idx] = new_backref
232+
224233
# in the cloned tree, look for other toctrees that we can include
225234
# into our new single tree
226235
toctreenodes = list(findall(tree, addnodes.toctree))

0 commit comments

Comments
 (0)