Skip to content

Commit

Permalink
Fix wrong anchors for non-latin headings (#3981) (#512)
Browse files Browse the repository at this point in the history
Change Javascript regular expression to match non-latin characters
The regex comes from here: http://stackoverflow.com/questions/150033/regular-expression-to-match-non-english-characters#comment22322603_150078

And this patch should fixed these two issues: #3919 #3843
  • Loading branch information
Bwko authored and lunny committed Dec 31, 2016
1 parent 6e5fffb commit 9ccc369
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ $(document).ready(function () {
var headers = {};
$(this).find('h1, h2, h3, h4, h5, h6').each(function () {
var node = $(this);
var val = encodeURIComponent(node.text().toLowerCase().replace(/[^\w\- ]/g, '').replace(/[ ]/g, '-'));
var val = encodeURIComponent(node.text().toLowerCase().replace(/[^\u00C0-\u1FFF\u2C00-\uD7FF\w\- ]/g, '').replace(/[ ]/g, '-'));
var name = val;
if (headers[val] > 0) {
name = val + '-' + headers[val];
Expand Down

0 comments on commit 9ccc369

Please sign in to comment.