Skip to main content

URL slug generation with transliteration and uniqueness

Project description

philiprehberger-slug

Tests PyPI version License

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.2.tar.gz (4.2 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.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: philiprehberger_slug-0.1.2.tar.gz
  • Upload date:
  • Size: 4.2 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.2.tar.gz
Algorithm Hash digest
SHA256 f1a442da40b231272026bc1e7108c2cced3df87e866857dacc837c61daeded0f
MD5 10eac00a57d53eed55184ab06daa4b70
BLAKE2b-256 fa6b85bbe6a4fd4048fb8f542e9b72e72e8eb4191c77f6651e1026109f72b1c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_slug-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e89839426a680f46cc9684f887798648a85ba79840c5be3d7e5e7e6e905c8fd1
MD5 9ff95472247c3bdbd240955b92e9d268
BLAKE2b-256 c051c7c116fa7ccd9af10a668fb41ce45064731efcdbd22b773f2d2ad0926fa5

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