Quicklisp Build Status Circle CI Coverage Status

Easily create slugs from any string. Supports many languages alphabets. See Supported languages to check for supported languages or to help to add one.

Inspired by Lisp Web Tales.


* (ql:quickload :cl-slug)
; => (:CL-SLUG)
* (import '(slug:slugify slug:asciify slug:CamelCaseFy))
; => T

The main function is called slugify:

* (slugify "My new cool article, for the blog (V. 2).")
; => "my-new-cool-article-for-the-blog-v-2"
* (slugify "Andr? Miranda")
; => "andre-miranda"

slugify removes any accentuated character, replacing it with an unaccentuated equivalent, and any ponctuation (a ponctuation is a char that returns NIL for alphanumericp) and puts a dash (-) on it's place. You can change that by binding (of setfing) *slug-separator*:

* (let ((*slug-separator* #\_))
    (slugify "Testing the *slug-separator* var..."))
; => "testing_the_slug_separator_var"

slugify also ignores numbers:

* (slugify "one2three4five")
; => "one2three4five"

If you just want to remove accentuation and ponctuation of a given string, use asciify:

* (asciify "Eu Andr?!")
; => "Eu Andre!"

Or if you want a CamelCase, use CamelCaseFy:

* (CamelCaseFy "My new camel case string")
; => "MyNewCamelCaseString"

Available languages are stored in *available-languages*:

* slug:*available-languages*
((:TR . "T?rk?e (Turkish)") (:SV . "Svenska (Swedish)") (:FI . "Suomi (Finnish)") 
 (:UK . "?????????? (Ukrainian)") (:RU . "???????? (Russian)") (:RO . "Rom?n? (Romanian)")
 (:RM . "Rum?ntsch (Romansh)") (:PT . "Portugu?s (Portuguese)") (:PL . "Polski (Polish)")
 (:NO . "Norsk (Norwegian)") (:LT . "Lietuvi? (Lithuanian)") (:LV . "Latvie?u (Latvian)")
 (:LA . "Lingua Lat?na (Latin)") (:IT . "Italiano (Italian)") (:EL . "???????? (Greek)")
 (:FR . "Fran?ais (French)") (:EO . "Esperanto") (:ES . "Espa?ol (Spanish)") (:EN . "English")
 (:DE . "Deutsch (German)") (:DA . "Dansk (Danish)") (:CS . "?e?tina (Czech)")
 (:CURRENCY . "Currency"))


This library depends on CL-PPCRE. The test package uses the prove test library.


Available on Quicklisp:

(ql:quickload :cl-slug)

Supported languages

The languages that are supported right now are: - english - portuguese - esperanto - german - french - swedish - finnish - norwegian - danish - italian - spanish - romansh

Ported from Django(): - currency - romanian - lithuanian - latvian - polish - czesh - ukranian - russian - turkish - greek - latin

At the present moment, adding new languages is a fairly manual process: 1. Identify non-ASCII characters in a given language's alphabet 2. Stablish equivalence between the found characters and ASCII characters 3. Write them down in the code.

All those things can actually be done for most of the dominant western languages, but can't be applied for minor regional languages or many other non-latin languages from the whole world, like chinese. It's not generic and not scalable.

I couldn't think of a solution so far for this, but if you know a solution (even a partial one) I'd be glad to hear =].


If you find any bug or inconsistency in the code, or if you find it too hard to use, please, feel free to open an issue.


This library is tested under ABCL, SBCL, CCL, CLISP and ECL Common Lisp implementations.

To run all the defined tests, use:

* (asdf:test-system :cl-slug)
; prints lots of (colorful) stuff...
; => T

Tests are ran with Travis CI and Circle CI using cl-travis, CIM, cl-coveralls and Roswell. Check it out!


Andr? Miranda.



Andr? Miranda
Andr? Miranda