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
72
72
* Joel Wurtz -- cellspanning support in LaTeX
73
73
* John Waltman -- Texinfo builder
74
74
* Jon Dufresne -- modernisation
75
+ * Jorge Marques -- singlehtml unique section ids
75
76
* Josip Dzolonga -- coverage builder
76
77
* Juan Luis Cano Rodríguez -- new tutorial (2021)
77
78
* Julien Palard -- Colspan and rowspan in text builder
Original file line number Diff line number Diff line change @@ -118,7 +118,9 @@ Bugs fixed
118
118
for objects documented as ``:py:data: `` to be hyperlinked in function signatures.
119
119
* #13858: doctest: doctest blocks are now correctly added to a group defined by the
120
120
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 ``.
122
124
123
125
Testing
124
126
-------
Original file line number Diff line number Diff line change 17
17
from sphinx .util .images import get_image_size
18
18
19
19
if TYPE_CHECKING :
20
- from docutils .nodes import Element , Node , Text
20
+ from docutils .nodes import Element , Node , Text , section
21
21
22
22
from sphinx .builders import Builder
23
23
from sphinx .builders .html import StandaloneHTMLBuilder
@@ -497,6 +497,15 @@ def depart_term(self, node: Element) -> None:
497
497
498
498
self .body .append ('</dt>' )
499
499
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
+
500
509
# overwritten
501
510
def visit_title (self , node : nodes .title ) -> None :
502
511
if (
You can’t perform that action at this time.
0 commit comments