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

Feature Request: Add an option to choose other slugify function #17

Open
twang2218 opened this issue Aug 19, 2016 · 5 comments
Open

Feature Request: Add an option to choose other slugify function #17

twang2218 opened this issue Aug 19, 2016 · 5 comments

Comments

@twang2218
Copy link

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 ?

@hcoona
Copy link
Contributor

hcoona commented Mar 6, 2017

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?

@mygu
Copy link

mygu commented Jun 22, 2018

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.

@curbengh
Copy link
Contributor

@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>

@mygu
Copy link

mygu commented Oct 9, 2019

@curbengh Yes, it's looks good. 👍

@curbengh
Copy link
Contributor

curbengh commented Oct 9, 2019

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.

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

No branches or pull requests

5 participants