diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-02-03 17:35:51 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-02-03 22:33:24 +0900 |
commit | b7c679626a652a4abe35633415c8665d1886950c (patch) | |
tree | e5fd399f8bbcc01d5a09eabdaa7a540ffe8bb64a | |
parent | ed3d13b9395a2df4914d460f40af65c9dfa57b7f (diff) | |
download | sphinx-git-b7c679626a652a4abe35633415c8665d1886950c.tar.gz |
Fix #5948: LaTeX: duplicated labels are generated for sections
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | sphinx/writers/latex.py | 5 | ||||
-rw-r--r-- | tests/roots/test-latex-labels/index.rst | 2 | ||||
-rw-r--r-- | tests/test_build_latex.py | 4 |
4 files changed, 9 insertions, 3 deletions
@@ -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 diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 3ada12c4d..c97554e6a 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1876,10 +1876,9 @@ class LaTeXTranslator(nodes.NodeVisitor): 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) diff --git a/tests/roots/test-latex-labels/index.rst b/tests/roots/test-latex-labels/index.rst index c55ee0b04..781db5a01 100644 --- a/tests/roots/test-latex-labels/index.rst +++ b/tests/roots/test-latex-labels/index.rst @@ -68,3 +68,5 @@ subsubsection .. toctree:: otherdoc + +* Embeded standalone hyperlink reference(refs: #5948): `subsection <section1_>`_. diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index fb481371c..b81d2a3fe 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -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 |