File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ Contributors
7272* Joel Wurtz -- cellspanning support in LaTeX
7373* John Waltman -- Texinfo builder
7474* Jon Dufresne -- modernisation
75+ * Jorge Marques -- singlehtml unique section ids
7576* Josip Dzolonga -- coverage builder
7677* Juan Luis Cano Rodríguez -- new tutorial (2021)
7778* Julien Palard -- Colspan and rowspan in text builder
Original file line number Diff line number Diff line change @@ -118,7 +118,9 @@ Bugs fixed
118118 for objects documented as ``:py:data: `` to be hyperlinked in function signatures.
119119* #13858: doctest: doctest blocks are now correctly added to a group defined by the
120120 configuration variable ``doctest_test_doctest_blocks ``.
121-
121+ * #13739: singlehtml builder: make section ids unique by appending the docname,
122+ matching ``sphinx/environment/adapters/toctree.py ``'s ``_resolve_toctree() ``
123+ format. E.g., ``id3 `` becomes ``document-path/to/doc#id3 ``.
122124
123125Testing
124126-------
Original file line number Diff line number Diff line change 1717from sphinx .util .images import get_image_size
1818
1919if TYPE_CHECKING :
20- from docutils .nodes import Element , Node , Text
20+ from docutils .nodes import Element , Node , Text , section
2121
2222 from sphinx .builders import Builder
2323 from sphinx .builders .html import StandaloneHTMLBuilder
@@ -497,6 +497,15 @@ def depart_term(self, node: Element) -> None:
497497
498498 self .body .append ('</dt>' )
499499
500+ def visit_section (self , node : section ) -> None :
501+ if self .builder .name == 'singlehtml' and node ['ids' ]:
502+ docname = self .docnames [- 1 ]
503+ node ['ids' ][0 ] = 'document-' + docname + '#' + node ['ids' ][0 ]
504+ super ().visit_section (node )
505+
506+ def depart_section (self , node : section ) -> None :
507+ super ().depart_section (node )
508+
500509 # overwritten
501510 def visit_title (self , node : nodes .title ) -> None :
502511 if (
You can’t perform that action at this time.
0 commit comments