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

Development

pip install -e .
python -m pytest tests/ -v

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for philiprehberger_slug-0.1.5.tar.gz
Algorithm Hash digest
SHA256 0c4f1426cdece3aa9f8eca03a7a50a699dbe31c55980b76a3f8596343fd4afea
MD5 0188515c6e951e56cd7c5e15cc612d75
BLAKE2b-256 607d250398e56910086800a257c53bdce26bbe7c98320199a1503b1cef68c6db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_slug-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 92cc5739bb7d55dee13c691fe4352821089eb58c7f4125fb01ef3fa2cc23102e
MD5 e657b9309c93305f20b91f25e60f50e5
BLAKE2b-256 d15db232b724e1d7093b7d98b787db45946be3d1bb3a7830ad4b8677e63a90d1

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