-
Notifications
You must be signed in to change notification settings - Fork 326
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
heading IDs are not unique vs manual html or curly-blocks #2832
Comments
No rush on this bug. Right now, even the TOC generator does not use the heading IDs for linking, it just uses page numbers. So, this bug will only appear for people knowingly and manually creating links to anchors. Hopefully they'll figure out the workaround (i.e. assign unique IDs to manually inserted html et al). |
Important to consider that repeated IDs or names will not break anything really, it will just prevent links and scripts to get the element, but should not break a brew. |
It's possible that we could inject a step right before the rendered Markdown gets pushed into the BrewRenderer display element which builds a list of all element IDs in the HTML document and then runs a deduplication process. |
Another note, headings IDs are not unique unless they are the same tag, if you have a |
OK, that is a problem then. The adding of heading A problem that will also be complicated with partial-rendering mode. |
This is an us problem, we render the Markdown one page at a time; I did suspect it would be unique if we rendered the whole thing at once. |
PR #3089 renders the whole document at once, so if/when it goes live, heading IDs will be unique throughout the entire brew and persist in the HTML, even when on a non-rendered page. A manually specified ID can still clash with an automatically generated one, though. |
#1430 also linked to this issue. |
Isn't this fixed by #3156? |
Not quite. We removed a blocker but still need to actually implement a global headerID list. |
If we need a global header list for things other than this, then we will need to move GFMheader code into markdown.js and extend it there. As I ( very little ) understand markdown extensions, even if we forked and/or extended the GFM header module, we have no way of passing in a current list of IDs ( if maintained in markdown.js ) or resetting the list ( if maintained in the extension. If we don't need the global header list for other things then I think we can close this, pending #3262 |
I have put together a PR that lets the GFM-Header-ID code behave the way we would like. |
We want to use such a list for #2840, for example. |
Renderer
v3
Browser
Chrome
Operating System
MacOS
What happened?
Heading markdown (
# A Heading
) gets rendered as htmlHn
elements with anid
attribute derived from the heading text (<h1 id="a-heading">A heading</h1>
). Marked will ensure the value of theid
attribute is unique among all heading elements it renders .. but does not consider any other elements with the sameid
.Other elements with the same
id
could come from manually inserted html (<table id="myTable">...
) and even from curly-blocks and curly-spans ({{#myID ...}}
) and also curly-injectors (*BOLD*{#myID}
).The heading IDs should be unique to the full render, not just other headings.
Additional: any
<a name="value"></a>
should also be considered and avoided, since links to those fragment targets compete for the same namespace.[Marking as bug because heading ids should be unique. Rare, esoteric, and obscure, and can be worked around.]
Code
The text was updated successfully, but these errors were encountered: