From 4333646c8ce3036e907ed36c6ad73cfda03b8b4b Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Mon, 14 Nov 2022 18:47:36 +0000 Subject: [PATCH] fix(subParsers): strip international punctuation from github headers (#950) --- src/subParsers/makehtml/heading.js | 2 +- .../features/#320.github-compatible-generated-header-id.html | 2 +- .../features/#320.github-compatible-generated-header-id.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/subParsers/makehtml/heading.js b/src/subParsers/makehtml/heading.js index 9ca040e..a4910b3 100644 --- a/src/subParsers/makehtml/heading.js +++ b/src/subParsers/makehtml/heading.js @@ -140,7 +140,7 @@ showdown.subParser('makehtml.heading.id', function (m, options, globals) { .replace(/¨D/g, '') // replace rest of the chars (&~$ are repeated as they might have been escaped) // borrowed from github's redcarpet (so they should produce similar results) - .replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g, '') + .replace(/[&+$,\/:;=?@"#{}|^¨¿?:~\[\]`、゠=…‥『』〝〟「」゠=…‥\\*(){}()[]【】%.。,¡!!'<>]/g, '') .toLowerCase(); } else if (options.rawHeaderId) { title = title diff --git a/test/functional/makehtml/cases/features/#320.github-compatible-generated-header-id.html b/test/functional/makehtml/cases/features/#320.github-compatible-generated-header-id.html index ed34b7b..a63809a 100644 --- a/test/functional/makehtml/cases/features/#320.github-compatible-generated-header-id.html +++ b/test/functional/makehtml/cases/features/#320.github-compatible-generated-header-id.html @@ -1,3 +1,3 @@

some header

-

some header with &+$,/:;=?@\"#{}|^~[]`\*()%.!' chars

+

some header with &+$,/:;=?@\"#{}|^¨¿?:~[]`゠=…‥『』〝〟「」\*(){}()[]【】%.。,¡!!' chars

another header > with < chars

diff --git a/test/functional/makehtml/cases/features/#320.github-compatible-generated-header-id.md b/test/functional/makehtml/cases/features/#320.github-compatible-generated-header-id.md index d547f42..773a5d6 100644 --- a/test/functional/makehtml/cases/features/#320.github-compatible-generated-header-id.md +++ b/test/functional/makehtml/cases/features/#320.github-compatible-generated-header-id.md @@ -1,5 +1,5 @@ # some header -# some header with &+$,/:;=?@\"#{}|^~[]`\\*()%.!' chars +# some header with &+$,/:;=?@\"#{}|^¨¿?:~[]`゠=…‥『』〝〟「」\\*(){}()[]【】%.。,¡!!' chars # another header > with < chars