File tree Expand file tree Collapse file tree 3 files changed +6
-24
lines changed Expand file tree Collapse file tree 3 files changed +6
-24
lines changed Original file line number Diff line number Diff line change @@ -1843,30 +1843,10 @@ def add_target(id: str) -> None:
1843
1843
and node ['refid' ] == prev_node ['refid' ]
1844
1844
):
1845
1845
# a target for a hyperlink reference having alias
1846
- pass
1846
+ return
1847
1847
else :
1848
1848
add_target (node ['refid' ])
1849
- # Temporary fix for https://github.com/sphinx-doc/sphinx/issues/11093
1850
- # TODO: investigate if a more elegant solution exists
1851
- # (see comments of https://github.com/sphinx-doc/sphinx/issues/11093)
1852
- if node .get ('ismod' , False ):
1853
- # Detect if the previous nodes are label targets. If so, remove
1854
- # the refid thereof from node['ids'] to avoid duplicated ids.
1855
- def has_dup_label (sib : Node | None ) -> bool :
1856
- return isinstance (sib , nodes .target ) and sib .get ('refid' ) in node ['ids' ]
1857
-
1858
- prev = get_prev_node (node )
1859
- if has_dup_label (prev ):
1860
- ids = node ['ids' ][:] # copy to avoid side-effects
1861
- while has_dup_label (prev ):
1862
- ids .remove (prev ['refid' ]) # type: ignore[index]
1863
- prev = get_prev_node (prev ) # type: ignore[arg-type]
1864
- else :
1865
- ids = iter (node ['ids' ]) # read-only iterator
1866
- else :
1867
- ids = iter (node ['ids' ]) # read-only iterator
1868
-
1869
- for id in ids :
1849
+ for id in node ['ids' ]:
1870
1850
add_target (id )
1871
1851
1872
1852
def depart_target (self , node : Element ) -> None :
Original file line number Diff line number Diff line change @@ -69,6 +69,6 @@ subsubsection
69
69
70
70
otherdoc
71
71
72
- * Embedded standalone hyperlink reference: `subsection <section1 _>`_.
72
+ * Named hyperlink reference with embedded alias reference: `subsection <section1 _>`_.
73
73
74
74
.. See: https://github.com/sphinx-doc/sphinx/issues/5948
Original file line number Diff line number Diff line change @@ -2019,9 +2019,11 @@ def test_latex_labels(app: SphinxTestApp) -> None:
2019
2019
r'\label{\detokenize{otherdoc::doc}}'
2020
2020
) in result
2021
2021
2022
- # Embedded standalone hyperlink reference
2022
+ # Named hyperlink reference with embedded alias reference
2023
2023
# See: https://github.com/sphinx-doc/sphinx/issues/5948
2024
2024
assert result .count (r'\label{\detokenize{index:section1}}' ) == 1
2025
+ # https://github.com/sphinx-doc/sphinx/issues/13609
2026
+ assert r'\phantomsection\label{\detokenize{index:id' not in result
2025
2027
2026
2028
2027
2029
@pytest .mark .sphinx ('latex' , testroot = 'latex-figure-in-admonition' )
You can’t perform that action at this time.
0 commit comments