Skip to content

LaTeX: revisit and trim visit_target() #13616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jfbu
Copy link
Contributor

@jfbu jfbu commented Jun 5, 2025

Refs: #13609, #11093 (#11333), #6026 (#6051).

Nota bene: this commit does not revert "Tests: update LaTeX label test expectations from Docutils r10151 (#13610)" (commit 68d5610) as it is still necessary for compatibility with both Docutils 0.21.2 and Docutils HEAD at their r10151.

Refs: sphinx-doc#13609, sphinx-doc#11093 (sphinx-doc#11333), sphinx-doc#6026 (sphinx-doc#6051).

- Fix misnomer in test-latex-labels/index.rst text.

  Refs:
  sphinx-doc#13609 (comment)

- Patch writers/latex.py as per the proposal at end of:
  sphinx-doc#13609 (comment)

- Update test_latex_build.py::test_latex_labels to detect non
  desired extra label in LaTeX output.

Nota bene: this commit does not revert "Tests: update LaTeX label
test expectations from Docutils r10151 (sphinx-doc#13610)" (commit
68d5610) as it is still
necessary for compatibility with both Docutils 0.21.2 and
Docutils HEAD at their r10151.
@jfbu jfbu requested a review from picnixz June 5, 2025 09:02
# See: https://github.com/sphinx-doc/sphinx/issues/5948
assert result.count(r'\label{\detokenize{index:section1}}') == 1
# https://github.com/sphinx-doc/sphinx/issues/13609
assert r'\phantomsection\label{\detokenize{index:id' not in result
Copy link
Contributor Author

@jfbu jfbu Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other LaTeX labels (apart from \phantomsection\label{\detokenize{index::doc}} one sees at start of document body do not use \phantomsection because they follow either a \section/\chapter (et al.) or a \caption and Sphinx LaTeX writer then does not inject unneeded \phantomsection. The named hyperlink reference with embedded alias on the other hand caused with Docutils HEAD at r10151 or later an extra \phantomsection\label which this detects.

@gmilde
Copy link

gmilde commented Jun 5, 2025

The patch looks good to me to solve the test output issue.
(Some issues discussed in #13609 remain open.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants