Skip to content

Argument to make flugified strings valid XML id attributes. #150

Description

@jenstroeger

Thank you for this great package! I have a question/feature request, though.

Suppose I have a call like this:

>>> slugify.slugify("1: Into the Dark")
'1-into-the-dark'

which is an invalid XML id attribute because it starts with a number (see also xml:id spec and NCName definition).

Would it make sense to add a valid_xml_id=True argument to the slugify() function? My current approach is somewhat naive:

slug = slugify.slugify(chapter_title, max_length=32)
if regex.fullmatch(r"^\d+.*", slug):
    slug = f"chapter-{slug}"

but I think having support from slugify() might benefit others, too? Happy to attempt a PR, if it helps.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions