Skip to content
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

handle nbsp (nonbreaking space) in headings #141

Closed
zebapy opened this issue Jun 16, 2020 · 3 comments · Fixed by #159
Closed

handle nbsp (nonbreaking space) in headings #141

zebapy opened this issue Jun 16, 2020 · 3 comments · Fixed by #159

Comments

@zebapy
Copy link

zebapy commented Jun 16, 2020

Our site uses a plugin to prevent widows by adding a   between the last 2 words of most elements (h1, p, etc).

When using anchorjs, this is causing some headings to come out as

<h2 id="where-to&nbsp;start">Where to&nbsp;Start?
<a class="anchorjs-link " aria-label="Anchor" data-anchorjs-icon="" href="#where-to&nbsp;start"></a>
</h2>

Everything is functional but the anchor link suffers in readability after.

@bryanbraun
Copy link
Owner

bryanbraun commented Jun 19, 2020

@zebapy, I'm on board with this.

It's definitely an edge-case, but a good-enough solution seems pretty low-overhead and straightforward.

As for the approach, he looks nice but I want to keep anchorjs dependency-free. I like the simplicity of the textarea approach. It shouldn't be hard to add it at the beginning of our urlify function, and add a test for it.

The biggest downside of this change is that it would require at least a minor (if not major) version bump, since we could be potentially changing link locations for existing users. I'm ok with that, but if I'm doing a major version bump, I want to include #109 in it as well.

Feel free to submit a PR if you want to take a pass at this. Otherwise, I'll get to it eventually.

@zebapy
Copy link
Author

zebapy commented Jul 9, 2020

I'm also encountering curly quotes and degree icons not being replaced with nothing. #there’s-a-heading-after-intro-360°-degrees

@bryanbraun
Copy link
Owner

bryanbraun commented Jul 11, 2020

@zebapy, the quotes and degree icons are a part of the decision to support UTF-8 characters (except for a small set of non-safe characters). I had originally stripped out these kinds of characters, but I changed the approach in order to better support international characters. For more background on that decision, see: #41

The &nbsp; showing up is different to me, since that's not an instance of a UTF-8 character, and I don't know of anybody who would want to see those in their urls. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants