-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Adding multiple titles/headers with the same content produces invalid markup. #82
Comments
I'm working on this issue after noticing ids were being added during a bug fix for Ghost. |
In addition to incrementing a unique identifier for ids, we should also prefix the id with a namespace. Allowing users who leverage this library as a content editing system opens the door for them to inadvertently match existing style rules based on the header id/content. (Exactly what's happening in Ghost) I'm proposing a format similar to the following:
|
…header ids. closes showdownjs#82 - Modified header id function to prepend `section` to each id - Modified header id function to track duplicate count and append a unique numerical-id
A side-note for this fix/hack: Users really shouldn't be creating duplicate headers to begin with. Personally, I feel like the library should warn when this happens and not allow for duplicates or any other invalid/non-semantic markup. This would bring an entirely new purpose (markup validation) into the responsibilities of this library, so we should definitely spin off a new thread to deal with that if necessary -- I just wanted to note the underlying issue here. |
@nicovalencia I think duplicate headers should be allowed and is all fine. What if I have something like
Now you're idea about using a suffix counter is an interesting workaround. As an addition: would it make sense to add the original section title as a class (for invariable styling)? |
Once we merge the v2 branch, c367a4b will close this. @nicovalencia contribution should be mentioned though, somewhere appropriate. |
Makes sense to me -- thank you @tivie! 🍰 |
Creating a title/header adds the content of the header to the header markup tag's
id
attribute.For example:
produces:
If setting an
id
attribute is necessary for #hash linking, it should keep track of duplicates appending a unique identifier. e.g.foobar-1
,foobar-2
, etc or a timestampfoobar-1389214127156
,foobar-1389214127157
, etc.If setting an
id
attribute is unnecessary, this functionality should be removed altogether.The text was updated successfully, but these errors were encountered: