Skip to content
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

Duplicated Title in TOC do not generate correct links with singlehtml #13149

Open
Agadoul opened this issue Nov 21, 2024 · 2 comments
Open

Duplicated Title in TOC do not generate correct links with singlehtml #13149

Agadoul opened this issue Nov 21, 2024 · 2 comments

Comments

@Agadoul
Copy link

Agadoul commented Nov 21, 2024

Describe the bug

I have a singlehtml file generated from multiple rst.

in index.rst, there is a toctree drective to include other rst file.

Those rsts files contains multiple section. I have enabled autosectionlabel but a correct link is only generated for the main section not for the other section.

For example, the html:

<ul>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-1_introduction">1. Introduction</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#purpose">1.1. Purpose</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#content">1.2. Content</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="index.html#document-2_protocols">2. Protocols</a><ul>
<li class="toctree-l2"><a class="reference internal" href="index.html#purpose">2.1. Purpose</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#content">2.2. Content</a></li>
</ul>

#document-1_ should prefix other item as well.

so when i click on the second content object it will alway go to the first one

any idea ?
Best regards,

How to Reproduce

we need 3 rst files.

index.rst:

================================================================
A
================================================================

.. toctree::
   :maxdepth: 3
   :numbered:
   :caption: Contents:

   1_introduction
   2_protocols

1_introduction.rst

================================================================
Introduction
================================================================

A

----------------------------------------------------------------
Purpose
----------------------------------------------------------------

B

----------------------------------------------------------------
Content
----------------------------------------------------------------

C

2_protocols.rst

================================================================
Protocols
================================================================

C

----------------------------------------------------------------
Purpose
----------------------------------------------------------------

D

----------------------------------------------------------------
Content
----------------------------------------------------------------

E

Environment Information

Platform:              win32; (Windows-11-10.0.22621-SP0)
Python version:        3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)])
Python implementation: CPython
Sphinx version:        8.1.3
Docutils version:      0.20.1
Jinja2 version:        3.1.3
Pygments version:      2.17.2

Sphinx extensions

'sphinx.ext.doctest',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.autosectionlabel',

Additional context

No response

@mgeier
Copy link
Contributor

mgeier commented Nov 21, 2024

This sounds like a duplicate of #4814.

@Agadoul
Copy link
Author

Agadoul commented Nov 22, 2024

it looks very similar indeed. Any way to fix this via an extension or anything else. I can patch the html in a second phase after the generation but this is slightly ugly.

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

No branches or pull requests

2 participants