ソースを参照

cleanup of the code belonging to slugify

lukasepple 10 年 前
コミット
5aa89f4497
共有1 個のファイルを変更した9 個の追加8 個の削除を含む
  1. 9 8
      src/content.lisp

+ 9 - 8
src/content.lisp

@@ -20,21 +20,22 @@
20 20
   "Test if the slugs for tag A and B are equal."
21 21
   (string= (tag-slug a) (tag-slug b)))
22 22
 
23
-; Slugs
23
+;; Slugs
24 24
 
25
-(defun slug-char-p (char &key (allowed-chars (list #\- #\Space #\~)))
25
+(defun slug-char-p (char &key (allowed-chars (list #\- #\~)))
26 26
   "Determine if CHAR is a valid slug (i.e. URL) character."
27 27
   ; use the first char of the general unicode category as kind of
28 28
   ; hyper general category
29
-  (let ((cat (char (cl-unicode:general-category char) 0))
30
-		(allowed-cats (list #\L #\N)))
29
+  (let ((cat (aref (cl-unicode:general-category char) 0))
30
+		(allowed-cats (list #\L #\N))) ; allowed Unicode categories in URLs
31 31
 	(cond
32
-	  ((member cat allowed-cats)   't)
33
-	  ((member char allowed-chars) 't)
34
-	  (t 'nil))))
32
+	  ((member cat allowed-cats)   t)
33
+	  ((member char allowed-chars) t)
34
+	  (t nil))))
35 35
 
36 36
 (defun unicode-space-p (char)
37
-  (equal (char (cl-unicode:general-category char) 0) #\Z))
37
+  "Determine if CHAR is a kind of whitespace by unicode category means"
38
+  (char= (aref (cl-unicode:general-category char) 0) #\Z))
38 39
 
39 40
 (defun slugify (string)
40 41
   "Return a version of STRING suitable for use as a URL."