diff --git a/anchor-markdown-header.js b/anchor-markdown-header.js index 7993a73..4339297 100644 --- a/anchor-markdown-header.js +++ b/anchor-markdown-header.js @@ -23,9 +23,11 @@ function basicGithubId(text) { // escape codes .replace(/%([abcdef]|\d){2,2}/ig, '') // single chars that are removed - .replace(/[\/?!:\[\]`.,()*"';{}+=<>~\$|#@&–—]/g,'') + .replace(/[\/\\?!%:\[\]`.,()*"';{}+=<>~\$|#@&–—]/g,'') // CJK punctuations that are removed .replace(/[。?!,、;:“”【】()〔〕[]﹃﹄“ ”‘’﹁﹂—…-~《》〈〉「」]/g, '') + // latin-1 supplement chars that are removed + .replace(/[¡¢£¤¥¦§¨©«¬®¯±²³´¶·¸¹º»¼½¾¿]/g, '') ; } @@ -91,6 +93,7 @@ function getGitlabId(text, repetition) { .replace(/\s+/g, '-') // All spaces are converted to hyphens .replace(/[\/?!:\[\]`.,()*"';{}+=<>~\$|#@]/g,'') // All non-word text (e.g., punctuation, HTML) is removed .replace(/[。?!,、;:“”【】()〔〕[]﹃﹄“ ”‘’﹁﹂—…-~《》〈〉「」]/g, '') // remove CJK punctuations + .replace(/[¹²³]/g, '') // remove snall subset of latin-1 supplement chars .replace(/[-]+/g,'-') // duplicated hyphen .replace(/^-/,'') // ltrim hyphen .replace(/-$/,''); // rtrim hyphen diff --git a/test/anchor-markdown-header.js b/test/anchor-markdown-header.js index 5bb62cc..788cb6d 100644 --- a/test/anchor-markdown-header.js +++ b/test/anchor-markdown-header.js @@ -76,6 +76,9 @@ test('\ngenerating anchor in github mode', function (t) { , [ 'bar_foo', null, '#bar_foo'] , [ 'baz_foo_', null, '#baz_foo_'] , [ '_foo_bax_', null, '#foo_bax'] + , [ '10% off', null, '#10-off'] + , [ '1/2 affected', null, '#12-affected'] + , [ '¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿Latin 1', null, '#%C2%AA%C2%B0%C2%B5latin-1'] ].forEach(function (x) { check(x[0], x[1], x[2]) }); t.end();