-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Trim excess dashes from heading IDs #457
Conversation
@Feder1co5oave: Would this fix the failing test related to header IDs?? |
Nope. In fact, with that test it would have the same effect as applying #456 |
Bummer. Thinking about closing this then. Thoughts?? |
@Feder1co5oave: Just to make sure I'm picking up what you're putting down. Merging this won't fix the failing test. Merging this won't conflict with the #456 solution. Having said that, I thought I saw a PR (other than #456) elsewhere talking about the trailing dash heading issue. Now thinking about just merging this then. Trying to clean up PRs a bit. |
Let's put it this way: both this and #456 target the default generation of Commonmark does not even hint at id generation for headings. I guess GFM does, I haven't checked. Where generating ids, there are problems about punctuation, non-ansi characters, DOM clobbering and so on, that trying to solve them all is beyond our capabilities. There exist some libraries (I'm thinking uslug) that do just that. We could try to replicate the id generation of github... This pr tries to improve the default generation of id, but it doesn't solve any "real issues" |
@Feder1co5oave: I tend to agree. I haven't seen a Markdown spec that has This is what I was going for in #919 as well. I think there would be complaints; however, I think the integrity of Marked would be better served with an extensible solution like you describe. The core of Marked, imho, should be reserved for converting Markdown to HTML based on one or more specifications, with the option to extend. Having said that, one of the things I've always appreciated about Markdown is that it is not limited to converting to HTML; the more stuff we add that is HTMl specific the more it feels like we move away from this decoupling. Almost like we (Marked) are perpetuating the notion that Markdown is just a simpler way of writing HTML...instead of Markdown essentially being a markup language in and of itself. That's my philosophical contribution for the day. ;) Closing to be revisited at a later time. If we do something with the heading ids it will probably need to wait until 0.5.0 or later as we process the more pressing issue of spec compliance over new features. |
@joshbruce no problem for me. Should we open a dedicated issue to discuss default id generation? See #981 (comment) for a collection of id-related issues. |
@Feder1co5oave: That sounds like a wonderful idea. I'm moving between meetings at the moment, can you take that up? |
The dedicated issue thing. :) |
When I have something like
With the default Renderer I get
(notice the trailing dash in the id).
This PR fixes this:
Warning: this may change the way URLs are generated and break existing links.