Skip to main content

URL slug generation with transliteration and uniqueness

Project description

philiprehberger-slug

URL slug generation with transliteration and uniqueness.

Installation

pip install philiprehberger-slug

Usage

Basic Slugification

from philiprehberger_slug import slugify

slugify("Hello World!")        # "hello-world"
slugify("Ünïcödé Têxt")       # "unicode-text"
slugify("Straße nach München") # "strasse-nach-munchen"

Options

slugify("Hello World", separator="_")    # "hello_world"
slugify("Hello World", max_length=8)     # "hello"
slugify("Hello World", lowercase=False)  # "Hello-World"

Unique Slugs

from philiprehberger_slug import unique_slugify

existing = {"hello-world", "hello-world-2"}
unique_slugify("Hello World", existing)  # "hello-world-3"

Strip HTML

from philiprehberger_slug import strip_html

strip_html("<p>Hello <b>World</b></p>")  # "Hello World"

API

  • slugify(text, separator="-", max_length=0, lowercase=True) — Generate a URL-safe slug
  • unique_slugify(text, existing, separator="-", max_length=0) — Generate a unique slug with numeric suffix
  • strip_html(text) — Remove HTML tags from text

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

philiprehberger_slug-0.1.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_slug-0.1.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_slug-0.1.1.tar.gz.

File metadata

  • Download URL: philiprehberger_slug-0.1.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for philiprehberger_slug-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a1d83a54557292dbf03874aa71e40a2e228647a65e774ea1460a76935e77af34
MD5 40c18ec32a5a287c671c96fc7f21f360
BLAKE2b-256 c22c263827196b9f4559b0060ce1ed4d11d6377a98c54cf02407e33f6bae2a60

See more details on using hashes here.

File details

Details for the file philiprehberger_slug-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_slug-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8af87b963bfd422878d739055a5c246d97bd95d27232a01beb5cdb9af00cbffe
MD5 b275cb060f249d85394185972b10193b
BLAKE2b-256 7f0853c0f8adc151af68a377ed66018875680dfaa3e9a530e3bf84d050da36ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page