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.0.tar.gz (3.5 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.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: philiprehberger_slug-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 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.0.tar.gz
Algorithm Hash digest
SHA256 7c40f8c91189e67c8de44895f330795074b4b8ba6a52bcae93fdc16c78f20915
MD5 cc9dc8fbde342644dc3da1e2e2a71001
BLAKE2b-256 162d3ec654ebb891867b4b0385a9fb10b4645b943e774cd465e3d36ff12014a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_slug-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 722b9f72f364e5be9e48b5d0a2948f0a097622a732138502bf2c2d9b422064ed
MD5 1dc33795bd4953978d0a1a752d22a7ca
BLAKE2b-256 af1854e367aa8f33f6e87cf16fd67c760a2e414831e3cebbffa5e4053961d9a4

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