Closed ouuan closed 2 years ago
Hi Yufan!
Would you provide an example where you would use the same heading in several sections in a Markdown doc?
PRs are welcome to create an Object counter, that keeps track of how many times a given heading has appeared, suffixing it with numbers if it already exists (counter + 1).
Is your feature request related to a problem? Please describe.
When using
@islands/headings
, if multiple headings have the same name, now they will share the same slug, and then the anchor will only work for the first heading with the shared name.Describe the solution you'd like
Rename the slug when multiple headings have the same name. For example, if the slug
foo
is already used, we can givefoo-2
to the next heading whose name isfoo
, and then givefoo-3
to the next one whose name isfoo
, and then maybe givefoo-3-2
to a heading whose name isfoo-3
.Describe alternatives you've considered
Avoid duplicated headings when writing Markdown.