A.String.slugify
You're seeing just the function
slugify
, go back to A.String module for more information.
Specs
Transforms the text as a slug. Removes whitespace, special characters and converts the rest to lowercase.
This is typically useful to generate URLs based on content, e.g. the title of an article.
Like String.downcase/2
, slugify/2
also can handle the following modes:
:default
(keeps unicode), :ascii
or :greek
.
Examples
iex> A.String.slugify("> \"It Was Me, Dio!!!\"\n")
"it-was-me-dio"
iex> A.String.slugify("Joseph Joestar a.k.a ジョジョ")
"joseph-joestar-aka-ジョジョ"
iex> A.String.slugify(<<220>>)
** (ArgumentError) Invalid string <<220>>
:ascii
converts to ascii when possible or strips characters:
iex> A.String.slugify("OLÁ!\n", :ascii)
"ola"
iex> A.String.slugify("DIOの世界 -さらば友よ- ", :ascii)
"dio"
:greek
handles the context sensitive sigma in Greek:
iex> A.String.slugify("\tΣΣ?")
"σσ"
iex> A.String.slugify("\tΣΣ?", :greek)
"σς"