Skip to content

Commit

Permalink
Merge pull request #6006 from tk0miya/5948_duplicated_labels
Browse files Browse the repository at this point in the history
Fix #5948: LaTeX: duplicated labels are generated for sections
  • Loading branch information
tk0miya committed Feb 3, 2019
2 parents ed3d13b + b7c6796 commit 4c3ce03
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Bugs fixed
* #5954: ``:scale:`` image option may break PDF build if image in an admonition
* #5960: LaTeX: modified PDF layout since September 2018 TeXLive update of
:file:`parskip.sty`
* #5948: LaTeX: duplicated labels are generated for sections
* #5958: versionadded directive causes crash with Python 3.5.0
* #5995: autodoc: autodoc_mock_imports conflict with metaclass on Python 3.7
* #5871: texinfo: a section title ``.`` is not allowed
Expand Down
5 changes: 2 additions & 3 deletions sphinx/writers/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1876,10 +1876,9 @@ def add_target(id):
elif domain.get_enumerable_node_type(next_node) and domain.get_numfig_title(next_node):
return

if 'refuri' in node:
if 'refuri' in node or 'refid' in node or 'refname' in node:
# skip indirect targets (external hyperlink and internal links)
return
if node.get('refid'):
add_target(node['refid'])
for id in node['ids']:
add_target(id)

Expand Down
2 changes: 2 additions & 0 deletions tests/roots/test-latex-labels/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ subsubsection
.. toctree::

otherdoc

* Embeded standalone hyperlink reference(refs: #5948): `subsection <section1_>`_.
4 changes: 4 additions & 0 deletions tests/test_build_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1336,3 +1336,7 @@ def test_latex_labels(app, status, warning):
assert ('\\subsection{otherdoc}\n'
r'\label{\detokenize{otherdoc:otherdoc}}'
r'\label{\detokenize{otherdoc::doc}}' in result)


# Embeded standalone hyperlink reference (refs: #5948)
assert result.count(r'\label{\detokenize{index:section1}}') == 1

0 comments on commit 4c3ce03

Please sign in to comment.