fix: tag like C++ and C# are treated as a same tag

This commit is contained in:
Talha Mansoor 2019-11-30 22:09:19 +05:00
commit 2217f0e755
No known key found for this signature in database
GPG key ID: 002B80DA805650B7
2 changed files with 5 additions and 3 deletions

View file

@ -144,7 +144,9 @@ DEFAULT_CONFIG = {
'TEMPLATE_EXTENSIONS': ['.html'],
'IGNORE_FILES': ['.#*'],
'SLUG_REGEX_SUBSTITUTIONS': [
(r'[^\w\s-]', ''), # remove non-alphabetical/whitespace/'-' chars
# remove all characters except alphanumeric, whitespace,
# '_', '-', '+', '#' characters
(r'[^\w\s\-#\+]', ''),
(r'(?u)\A\s*', ''), # strip leading whitespace
(r'(?u)\s*\Z', ''), # strip trailing whitespace
(r'[-\s]+', '-'), # reduce multiple whitespace or '-' to single '-'
@ -387,7 +389,7 @@ def handle_deprecated_settings(settings):
if replace:
regex_subs += [
(r'[^\w\s-]', ''),
(r'[^\w\s\-#\+]', ''),
(r'(?u)\A\s*', ''),
(r'(?u)\s*\Z', ''),
(r'[-\s]+', '-'),

View file

@ -125,7 +125,7 @@ class TestUtils(LoggedTestCase):
def test_slugify_substitute(self):
samples = (('C++ is based on C', 'cpp-is-based-on-c'),
('C+++ test C+ test', 'cpp-test-c-test'),
('C+++ test C+ test', 'cpp+-test-c+-test'),
('c++, c#, C#, C++', 'cpp-c-sharp-c-sharp-cpp'),
('c++-streams', 'cpp-streams'),)