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.3.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.3-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: philiprehberger_slug-0.1.3.tar.gz
  • Upload date:
  • Size: 4.2 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.3.tar.gz
Algorithm Hash digest
SHA256 d474c0b1fae31526dc804a7ef3669180a7266229bbb671bc40cb0dcf7cf23fcc
MD5 8b01b8dc224160b097af5986fc100eee
BLAKE2b-256 139b1f2e54ede75b0ac259e1c66d6999a93b6ae81c8a7ce7ea9ebf17d004a8c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_slug-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 19502ba85d34a5aefbe26feb27c160311d5715531b833c02547b435659af09f9
MD5 b3cfc9359a263f68b441d164bc2c4dba
BLAKE2b-256 c939fd7d511a752a714871d903e390fb620a0442064c757a7b8c274e1a344921

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