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

Headings containing a hashtag yield invalid hrefs #103

Closed
AleksandrHovhannisyan opened this issue Jul 23, 2021 · 2 comments
Closed

Headings containing a hashtag yield invalid hrefs #103

AleksandrHovhannisyan opened this issue Jul 23, 2021 · 2 comments

Comments

@AleksandrHovhannisyan
Copy link

One thing I noticed today is that one of my pages is giving me HTML validation errors because it has a heading of the form:

# Approach #1: Do something

And that nested hashtag yields this invalid anchor URL:

#approach-#1-do-something

Would it be possible to remove this special character from the output href since it's not allowed to appear more than once?

@AleksandrHovhannisyan AleksandrHovhannisyan changed the title Headings containing a hashtag yield invalid hrefs containing more than one hashtag Headings containing a hashtag yield invalid hrefs Jul 23, 2021
@valeriangalliat
Copy link
Owner

Hey! We use encodeURIComponent as the defaut slugify function so out of the box your example should output:

<h1 id="approach-%231%3A-do-something" tabindex="-1">Approach #1: Do something</h1>

Did you customize the slugify function? Also what HTML validator are you using?

@AleksandrHovhannisyan
Copy link
Author

Ah, that explains it! Yes, I customized it, and my custom slugify function wasn't handling that character. Thanks for the super quick response!

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

No branches or pull requests

2 participants