From 61b08fe9131ecda4b37881434cc2e805ae5f9d2e Mon Sep 17 00:00:00 2001 From: Jason Bohrer Date: Mon, 16 Apr 2018 20:59:24 -0400 Subject: [PATCH] Allow non-alphanumeric characters in slug Currently, users are unable to retain non-alphanumeric characters in their URLs unless a substitution specified in their SLUG_SUBSTITUTIONS setting effects a change in their URL. With this change users will be able to use non-alphanumeric characters without having to jump through an extra hoop. This may require a rework (placement into a different setting?) because it will break backwards compatibility for some users who rely on this behavior. --- pelican/utils.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pelican/utils.py b/pelican/utils.py index 1738de22..3f3a27c2 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -299,10 +299,8 @@ def slugify(value, substitutions=()): for src, dst, skip in substitutions: orig_value = value value = value.replace(src.lower(), dst.lower()) - # if replacement was made then skip non-alphanum - # replacement if instructed to do so - if value != orig_value: - replace = replace and not skip + # skip non-alphanum replacement if instructed to do so + replace = replace and not skip if replace: value = re.sub(r'[^\w\s-]', '', value).strip()