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

Distill TOC not working with special characters (e.g. ', ?) #489

Closed
3 tasks done
LoryPack opened this issue Dec 4, 2021 · 4 comments · Fixed by #519
Closed
3 tasks done

Distill TOC not working with special characters (e.g. ', ?) #489

LoryPack opened this issue Dec 4, 2021 · 4 comments · Fixed by #519
Labels

Comments

@LoryPack
Copy link
Contributor

LoryPack commented Dec 4, 2021

Acknowledge the following

  • I carefully read and followed the Getting Started guide.
  • I read through FAQ and searched through the past issues, none of which addressed my issue.
  • The issue I am raising is a potential bug in al-folio and not just a usage question.
    [For usage questions, please post in the Discussions instead of raising an issue.]

Describe the bug
I have added the TOC to my distill blog posts, following #470. That works fine. However, if the section or subsection contain special characters (as for instance apostrophe ' or question mark ?), the links in the table of contents do not work.

To Reproduce
Steps to reproduce the behavior:
Simply create a distill blog post, add a section with a question mark and add it to the TOC.

An example is present in my blog post here. See also the source code on Github here.

Expected behavior
TOC link should work.

System (please complete the following information):

  • OS: Linux, Ubuntu 20.04
  • Browser (and its version) Firefox 94.0
  • Jekyll version: 3.9.0
  • Ruby version: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
@LoryPack LoryPack added the bug label Dec 4, 2021
@alshedivat
Copy link
Owner

@LoryPack, thanks for raising this issue.

do you mind testing something quick for me in your blog? if you edit _layouts/distill.html and change #{{ section.name | downcase | replace: ' ','-' }} to #{{ section.name | handleize }} on lines 75 and 79, does that help? thanks.

@LoryPack
Copy link
Contributor Author

LoryPack commented Jan 2, 2022

Hello, thanks for that. I have tried what you suggest, but if you do that no link in TOC works!

I realized the issue in the first place is not due to the links in TOC. In fact, if I remove the TOC from the blog post, still the links with # go to the right section, except for the ones in which a "?" or " ' " appear. For instance, in my example, going to
http://www.lorenzopacchiardi.me/blog/2021/generalizedBayes/#power-likelihood

goes to the right section, while

http://www.lorenzopacchiardi.me/blog/2021/generalizedBayes/#so-what-is-wrong?

does not, even if no TOC is present.

@alshedivat
Copy link
Owner

@LoryPack, makes sense. looks like handleize is not a valid jekyll filter; the correct one is slugify. #519 should fix the issue (see code changes here). please check and let me know if it works on your end. thanks!

@LoryPack
Copy link
Contributor Author

LoryPack commented Jan 3, 2022

Seems to be working now, thanks a lot!

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

Successfully merging a pull request may close this issue.

2 participants