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 non-ASCII strings in header anchors #591

Merged
merged 2 commits into from Dec 25, 2016

Conversation

sanmai
Copy link
Contributor

@sanmai sanmai commented Dec 21, 2016

Comes in two parts:

  1. First we fix an issue with a dangling quote in 8d8e1ec
  2. Next, in f2d0ad9 we handle empty anchors with a djb2 hash computed for the header

Overall it should fix #538 for Japanese and any other Unicode characters.

I considered adding heuristics to append a hash if more than X characters were removed, but decided against it because it may break someone's links. This may be beneficial if one have multiple headers in a foreign language that include some ASCII characters. Now every anchor for such headers would only contain said characters, giving duplicate anchors.

(sdbm implementation from hash_link_ref could be used instead of djb2, but that will introduce cross-dependencies)

Unlike #539 (which is also valid in principle) this change is self-contained. It doesn't depend on OpenSSL dev headers or anything else. Promise to require no installed libraries is kept.

@robin850 robin850 merged commit cf2da0b into vmg:master Dec 25, 2016
robin850 added a commit that referenced this pull request Dec 25, 2016
Add a test to ensure that the anchor is properly generated on the
HTML_TOC side as well and give proper credit.

:heart:
@robin850
Copy link
Collaborator

Thank you very much @sanmai, what a beautiful Christmas gift, this has been merged and I took the liberty to credit you in the CHANGELOG ! :-) Merry Christmas and happy new year ! 🎄 🎅 ❤️

@namusyaka
Copy link
Contributor

❤️💛💚💙💜

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 this pull request may close these issues.

with_toc_data with Japanese
3 participants