forked from preactjs/preact-www
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support non-alphanumeric characters in ToC
```js // Note: character range in regex is roughly "word characters including accented" (eg: bublé) const id = text .toLowerCase() .replace(/[\s-]+/g, '-') .replace(/[^a-z0-9\u00C0-\u024F-]/g, ''); // korean .replace(/[^가-힣]/g, ''); // Japanese hiragana, katakana, kanji .replace(/[^\u3041-\u3096\u30A0-\u30FF\u2E80-\u2FD5]/g, ''); ``` If want to keep existing intent, the above code might be more suitable. Reference issue comment: preactjs#754 (comment)
- Loading branch information
Showing
1 changed file
with
8 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters