You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
V0.3.6,<h1>,<h2>,<h3>,<h4>,<h5>,<h6>sometimes id are same #919
There's no perfect way to generate IDs. The "naive" way to fix this would be to add a numeric counter to duplicate IDs, but that would require keeping track of all IDs.
Step one: Convert Markdown to HTML.
Step two (DOM is ready/loaded): Cycle through the headers to add ID attributes and generate the TOC in one shot.
No JS solution = no TOC; therefore, no reason to have the IDs in the first place.
Again, could just be asking Marked to do too much. If a spec has it, we should too but, if a spec has it, it should define the testable rules for implementing the solution, yeah?
Note: I did not use Marked for processing back in the day.
Activity
destagia commentedon Aug 26, 2017
I have a same problem...
destagia commentedon Aug 26, 2017
I solved this by overriding
marked.Renderer#headingfunction.It seems to be natural to assume the above-mentioned behavior is a specification.
aianze commentedon Aug 30, 2017
I do it:
The full code is here
Update marked.js
[-]V0.3.6,<h1>,<h2> id are same[/-][+]V0.3.6,<h1>,<h2>,<h3>,<h4>,<h5>,<h6>sometimes id are same[/+]joshbruce commentedon Dec 25, 2017
#981
Feder1co5oave commentedon Jan 5, 2018
There's no perfect way to generate IDs. The "naive" way to fix this would be to add a numeric counter to duplicate IDs, but that would require keeping track of all IDs.
joshbruce commentedon Jan 5, 2018
I still think the easiest way is to not have Marked do it. This is what I used to do back in the day for scrolling table of contents a la Bootstrap - http://getbootstrap.com/2.3.2/getting-started.html
Step one: Convert Markdown to HTML.
Step two (DOM is ready/loaded): Cycle through the headers to add ID attributes and generate the TOC in one shot.
No JS solution = no TOC; therefore, no reason to have the IDs in the first place.
Again, could just be asking Marked to do too much. If a spec has it, we should too but, if a spec has it, it should define the testable rules for implementing the solution, yeah?
Note: I did not use Marked for processing back in the day.
yzfdjzwl commentedon Feb 8, 2018
@tagia0212
if your header includes
(), it will failure. eg:joshbruce commentedon Feb 11, 2018
#1048
joshbruce commentedon Apr 13, 2018
Closing as most likely going to be deprecated at a later date.
Grawl commentedon Oct 12, 2018
The problem still exists.
styfle commentedon Oct 12, 2018
Yes, this problem still exists.
Let's consolidate this issue with a similar one here: #1280
joshbruce commentedon Oct 12, 2018
Sidenote: GitHub adding detail popovers on hover...fancy. 😎