kuon / elm-string-normalize / String.Normalize

Normalize string in different formats

Normalize formats

url : String -> String

url is similar to slug but will preserve slashes.

url "J'aime les fruits/et les amours" --> "j-aime-les-fruits/et-les-amours"

slug : String -> String

slug will remove all diacritics and punctuation, lowercase the string, collapse spaces and replace them with hyphens. Trailing and leading hyphens will be removed.

slug "Écoute la vie!" -> "ecoute-la-vie"
slug "(this is not interesting!)" -> "this-is-not-interesting"
slug "é()/& abc  -" --> "e-abc"

filename : String -> String

filename is similar to slug but will use underscores instead of hypens, it will also preserve the file extension. The file extension will be lowercased.

filename "J'aime les fruits/et les amours .MP3"
    -->
    "j_aime_les_fruits_et_les_amours.mp3"

path : String -> String

path is similar to filename but will preserve slash.

path "J'aime les fruits/et les amours .MP3"
    -->
    "j_aime_les_fruits/et_les_amours.mp3"

Utilities

removeDiacritics : String -> String

removeDiacritics removes diactritics, it will expand known ligatures, thus changing the string glyph length. All non latin characters are untouched.

removeDiacritics "La liberté commence où l'ignorance finit."


--> "La liberte commence ou l'ignorance finit."
removeDiacritics "é()/& abc" --> "e()/& abc"

removeDiacritics "こんにちは" --> "こんにちは"