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

The function generate_toc_id isn't setup for unicode #170

Open
kylerove opened this issue Feb 23, 2023 · 1 comment
Open

The function generate_toc_id isn't setup for unicode #170

kylerove opened this issue Feb 23, 2023 · 1 comment

Comments

@kylerove
Copy link

kylerove commented Feb 23, 2023

I want to be able to dynamically create anchors to header elements outside the TOC, ideally using the built-in Jekyll slugify: latin filter. Example:

<h2 id="rin">Riñón</h2>

The anchor id drops non-latin characters. Sadly, this behavior doesn't match slugify filter options of pretty, ascii, or latin. Because the routines do not match, I cannot dynamically create a link that specifies this link. Of course, there are ways around this, but would be cool if the "slugs" created by this plugin could match jekyll slugify output with a setting or by default.

@cuquet
Copy link

cuquet commented Jun 30, 2024

Maybe my "home made patch" on jekyll-toc/lib/table_of_contents/helper.rb could help you. Just after PUNCTUATION_REGEXP = /[^\p{Word}\- ]/u.freeze, I have add:

ERASEHTML_REGEXP = "(<\/?[^>]*>)|([\/]|[.·]|[à-ü]|[À-Ü])"

and this just after #remove punctuation line

.gsub(ERASEHTML_REGEXP, '')

demo of regular expression is available here

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