1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Trim leading and trailing hyphens from slug

This commit is contained in:
Aidan Woods 2020-05-05 19:11:02 +01:00
parent d8bf07535c
commit 4e99e29d28
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -25,6 +25,7 @@ final class HeaderSlug implements Configurable
$slug = \mb_strtolower($text); $slug = \mb_strtolower($text);
$slug = \str_replace(' ', '-', $slug); $slug = \str_replace(' ', '-', $slug);
$slug = \preg_replace('/[^\p{L}\p{Nd}\p{Nl}\p{M}-]+/u', '', $slug); $slug = \preg_replace('/[^\p{L}\p{Nd}\p{Nl}\p{M}-]+/u', '', $slug);
$slug = \trim($slug, '-');
return $slug; return $slug;
}; };