diff --git a/pyproject.toml b/pyproject.toml index cc4a1cf..dac1c94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,12 +17,12 @@ namespaces = true # ----------------------------------------- Project Metadata ------------------------------------- # [project] -version = "0.0.0.dev68" +version = "0.0.0.dev69" name = "PyLinks" dependencies = [ "requests >= 2.31.0, < 3", - "ExceptionMan == 0.0.0.dev55", - "MDit == 0.0.0.dev55", + "ExceptionMan == 0.0.0.dev56", + "MDit == 0.0.0.dev56", ] requires-python = ">=3.10" diff --git a/requirements.txt b/requirements.txt index 0152410..328fd27 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ requests >= 2.31.0, < 3 -ExceptionMan == 0.0.0.dev55 -MDit == 0.0.0.dev55 \ No newline at end of file +ExceptionMan == 0.0.0.dev56 +MDit == 0.0.0.dev56 \ No newline at end of file diff --git a/src/pylinks/string.py b/src/pylinks/string.py index 82726df..3db9fd2 100644 --- a/src/pylinks/string.py +++ b/src/pylinks/string.py @@ -2,7 +2,7 @@ import unicodedata as _unicodedata -def to_slug(string: str) -> str: +def to_slug(string: str, reduce: bool = True) -> str: """Convert a string to a URL-friendly slug. This function performs unicode-normalization on the string, @@ -17,7 +17,9 @@ def to_slug(string: str) -> str: # Decode back to a string ascii_string = ascii_bytes.decode('ascii') lower_case_string = ascii_string.lower() - return _re.sub(r'[^a-z0-9]+', '-', lower_case_string).strip('-') + if reduce: + return _re.sub(r'[^a-z0-9]+', '-', lower_case_string).strip('-') + return _re.sub(r'[^a-z0-9]', '-', lower_case_string) def camel_to_title(string: str) -> str: