-
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
Fix Heading ID for Unicode text #1374
Conversation
Defining `nonWordCharacters` seems to solve it. Reference: [atom nonWordCharacters](https://github.com/atom/atom/blob/080d6ae1279c66e5f018d803186a0cde5c202c03/src/config-schema.js?fbclid=IwAR0BI3l0KgHls4gGlFw0HYQ_G_U7A84X0eTtmSvfEauo8NCnQxpRKuGJnQM#L450)
according to the spec:
so couldn't we change it to |
I suppose we would want to remove All other characters seem to work fine in ids on chrome. |
Maybe, need to consider the behavior of shared URL with fragment (section ID). e.g. I'm sorry, I closed it by mistake in the mark down test. |
This feature (header id) is being removed in PR #1354 so I don't think it's worth pursuing in this PR. |
Thanks😄 |
I want to eliminate this problem quickly, so I reopened with a simple code adjustment. |
@styfle do we want to add a |
@UziTech If we are not going to remove it, we could go all-out and implement like so: function Slugger () {
this.seen = {};
}
Slugger.prototype.slug = function (value) {
var slug = value
.toLowerCase()
.trim()
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
.replace(/\s/g, '-');
var count = this.seen.hasOwnProperty(slug) ? this.seen[slug] + 1 : 0;
this.seen[slug] = count;
if (count > 0) {
slug = slug + '-' + count;
}
return slug;
}; I think we'll need some unit tests to see what will and will not match as far as unicode goes. That was one of the reasons why I was trying to tear it out, so the implementation and tests could live in |
I think not having dependencies is one of the big benefits of marked so if we want to have ids be part of gfm we will need to incorporate slugger into our code. |
@k-utsumi Would you like to update this PR with the slugger or should I create a new PR? |
@styfle |
Yes, I will create a PR this weekend with the appropriate change. |
Closing in favor of #1401 |
I think defining
nonWordCharacters
will solve it.Reference: atom nonWordCharacters