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

[toc] markdown extension doesn't support multiple headers with identical content #9594

Closed
benintech opened this issue Dec 24, 2023 · 1 comment · Fixed by #9610
Closed

[toc] markdown extension doesn't support multiple headers with identical content #9594

benintech opened this issue Dec 24, 2023 · 1 comment · Fixed by #9610
Labels
bug It's a bug renderer About the note renderer

Comments

@benintech
Copy link

benintech commented Dec 24, 2023

Operating system

Android

Joplin version

2.13.10

Desktop version info

2.13.8

Current behaviour

Same behavior on both Linux (2.5.8) and Android (2.5.10). I guess on other platforms too.

When there are multiple headers with the same content (for example, ## mySubtitle and ## mySubtitle), clicking on the second instance in the table of content ([toc]) doesn't redirect to that second instance (nothing happens). It seems the [toc] markdown extension doesn't support multiple headers with identical content, only the first instance of the header works when clicking on it in the TOC.

Expected behaviour

Each TOC entry should redirect to the corresponding header.
Having multiple headers or sub-headers with the same content is something that can happen (e.g., having multiple identical subtitles, like # Title1 → ## mySubtitle and # Title2 → ## mySubtitle. I think Joplin's [toc] implementation should support that.

Logs

No response

@benintech benintech added the bug It's a bug label Dec 24, 2023
@personalizedrefrigerator
Copy link
Collaborator

personalizedrefrigerator commented Dec 24, 2023

For context, this is the generated HTML:

<nav class="table-of-contents">
    <ul>
        <li><a href="#toc-test">Toc test</a></li>
        <li><a href="#test">test</a></li>
        <li><a href="#test-1">test</a></li>
    </ul>
</nav>
<h1 id="toc-test" class="maps-to-line" source-line="2" source-line-end="3">Toc test</h1>
<h1 id="test" class="maps-to-line" source-line="4" source-line-end="5">test</h1>
<p class="maps-to-line" source-line="6" source-line-end="7">This is a test.</p>
<h1 id="test-2" class="maps-to-line" source-line="8" source-line-end="9">test</h1>
<p class="maps-to-line" source-line="10" source-line-end="11">Testing...</p>

Observe that the second test link in the table of contents links to a non-existent heading with id test-1 (headings have IDs toc-test, test, and test-2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It's a bug renderer About the note renderer
Projects
None yet
2 participants