-
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
don't create IDs for headers by default #326
Comments
What issues? If you want to avoid id collisions, just use the |
because it's another option and an opinionated feature. i don't want it at all. easier if it wasn't supported. |
I agree with this. It’s nice to have the option, but I think it makes more sense that it’s opt-in. |
I agree in 0.4.0 release it should be removed. |
I'd like to share my implementation of the header renderer with ID creation: myRenderer.heading = function(text, level, raw, options) {
return '<h'
+ level
+' id="'
+ options.headerPrefix
+ raw.toLowerCase().replace(/[^\wàùòèéì]+/g, '-').replace(/^\-+|\-+$/g, '')
+ '">'
+ text
+ '</h'
+ level
+ '>\n';
} It is useful to keep letters with accents (I included the Italian ones) and removes any leading or trailing dashes:
|
I also think it should be switched off by default, since it injects unexpected ids into markup and seems like pretty much opinionated option. Besides, it doesn't work with non-latin headers, which results in quite horrible ids |
+1 It's far too easy to create issues on a page with dynamically generated ids. At the least, if it's not going to be removed, it should be automatically prefixed with Aside from that, and not being able to easily add new custom token rules (not just overriding current ones); this is some fine code and has saved me time implementing a new MD editor. So thank you for your efforts, they are appreciated. |
+1 |
2 similar comments
+1 |
+1 |
Would love this feature -- the ID should be optional because there are many scenarios where it is obtrusive. |
This is easy to achieve. const marked = require('marked');
const renderer = new marked.Renderer();
renderer.heading = (text, level) => `<h${level}>${text}</h${level}>`;
marked.setOptions({renderer}); Have a nice Markdown life! |
See #956 If you are still interested in this, comment. |
Just sharing how I obtain IDs in the browser
|
since we can create custom renderers now, i don't see the point of including this by default. the default renderer should be minimal and simple, and it would close plenty of issues surrounding this issue.
The text was updated successfully, but these errors were encountered: