Fix links in table of contents caused by variation selector-16 (U+FE0F)

This commit is contained in:
Zach Borboa
2024-08-24 14:11:30 -04:00
parent 357d1201a0
commit 28abb78e2e
2 changed files with 15 additions and 3 deletions
+13 -1
View File
@@ -51,7 +51,19 @@ script=$(cat <<'EOF'
preg_match_all('/^### (.*)/m', $data, $matches);
$toc = [];
foreach ($matches['1'] as $match) {
$slug = strtolower(preg_replace('/[^A-Za-z-]/', '', str_replace(' ', '-', $match)));
$slug = urlencode(
strtolower(
str_replace(
' ',
'-',
preg_replace(
'/[^A-Za-z\x{FE0F} ]/u',
'',
$match,
),
)
)
);
$href = '#' . $slug;
$toc[] = '- [' . $match . '](' . $href . ')';
}