modules/text/slug.zzm

text-slug-0.0.1 documentation

Package

Name
text-slug
Version
0.0.1
Uploaded
2026-06-15 14:41:04
Dependencies
Metadata
zuzu-distribution.json
Archive
Download .tar.gz

NAME

text/slug - Stable text slugs for URLs and filenames.

SYNOPSIS

  from text/slug import slugify, slug_words, filename_slug, unique_slug;

  say( slugify("A Useful Thing!") );                 // a-useful-thing
  say( filename_slug("Quarterly Report", "pdf") );   // quarterly-report.pdf
  say( unique_slug([ "post", "post-2" ], "Post") );  // post-3

DESCRIPTION

This module turns text text into stable slugs. Whitespace and punctuation become separators, common non-ASCII letters are folded to ASCII, output is lower-case by default, and callers may supply stop words.

EXPORTED FUNCTIONS

  • slug_words(String text, Dict options?)

    Return the normalized slug words as an array.

  • slugify(String text, Dict options?)

    Return a separator-joined slug. Supported options are separator, lowercase, ascii, stop_words, and fallback.

  • filename_slug(String title, String extension?)

    Return a conservative filename using title as the basename and extension as an optional suffix.

  • unique_slug(existing, String title, Dict options?)

    Return a slug for title that does not already appear in existing. existing may be an Array, Bag, Set, Dict, or PairList.

COPYRIGHT AND LICENCE

text/slug is copyright Kit Calder.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.