hexo-util
hexo-util copied to clipboard
Feature Request: Add an option to choose other slugify function
The default slugize is very simple and fast, however, it's not that useful for CJK characters. Could you make it possible to choose another slugify function, such as https://github.com/andyhu/node-transliteration ?
Why don't you use other slugify function instead of this one? Do you want to change the default behavior of Hexo engine by assign anothor slugize
function?
I found that if the anchor point ID
is in chinese, it will not jump normally.
<a class="post-toc-link" href="#3-散列算法"></a>
<h2 id="3-散列算法">...</h2>
I think a slugize
is necessary to add chinese conversion methods, like the encodeURIComponent
or translation
.
@mygu
I recently worked on encodeURL()
with support of anchor.
In the example that you gave, what is the expected value for h2 id
?
should it be,
<h2 id="3-%E6%95%A3%E5%88%97%E7%AE%97%E6%B3%95">...</h2>
@curbengh Yes, it's looks good. :+1:
I don't think encodeURI() can be added to slugize, otherwise hexo new post "散列算法"
will result in the following front matter in the post,
title: %E6%95%A3%E5%88%97%E7%AE%97%E6%B3%95
In regards to your issue, I think encodeURI should be added to toc.js and hexo-renderer-marked instead.
Edit: I just tested
<html>
<head></head>
<body>
<a href="#3-散列算法">Description of Same-Page Links</a>
</br></br></br></br></br></br></br></br></br></br></br></br>
</br></br></br></br></br></br></br></br></br></br></br></br>
</br></br></br></br></br></br></br></br></br></br></br></br>
</br></br></br></br></br></br></br></br></br></br></br></br>
</br></br></br></br></br></br></br></br></br></br></br></br>
</br></br></br></br></br></br></br></br></br></br></br></br>
</br></br></br></br></br></br></br></br></br></br></br></br>
</br></br></br></br></br></br></br></br></br></br></br></br>
</br></br></br></br></br></br></br></br></br></br></br></br>
</br></br></br></br></br></br></br></br></br></br></br></br>
<h1 id="3-散列算法">Title</h1>
</body>
</html>
works for me (Firefox).
Longer text example.