From e1d4751a2273d11945ccc7886d995c456d6af3b1 Mon Sep 17 00:00:00 2001 From: Brit Butler Date: Mon, 20 Aug 2012 16:21:12 -0400 Subject: [PATCH] Add SLUGIFY. --- src/posts.lisp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/posts.lisp b/src/posts.lisp index 76e7565..b6feee7 100644 --- a/src/posts.lisp +++ b/src/posts.lisp @@ -33,3 +33,12 @@ ; TODO: Populate prev and next with links. :prev nil :next nil)))) + +(defun slug-char-p (char) + (or (char<= #\0 char #\9) + (char<= #\a char #\z) + (char<= #\A char #\Z) + (member char '(#\_ #\-)))) + +(defun slugify (string) + (remove-if-not #'slug-char-p (substitute #\- #\Space string)))