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, andfallback.filename_slug(String title, String extension?)Return a conservative filename using
titleas the basename andextensionas an optional suffix.unique_slug(existing, String title, Dict options?)Return a slug for
titlethat does not already appear inexisting.existingmay 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.