From eedd8f9f0b69a8d1a7a6d96cd028b2ecc4c92ed5 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 15 Mar 2022 16:46:02 +0530 Subject: tissue: Sanitize tag names in file paths. * tissue/web.scm (sanitize-string): New function. (issue-list-item-markup-writer-action, build-website): Use sanitize-string. --- tissue/web.scm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tissue/web.scm b/tissue/web.scm index 92d33a6..9f86cdb 100644 --- a/tissue/web.scm +++ b/tissue/web.scm @@ -97,6 +97,14 @@ NEW-EXTENSION." #:posts))) (body (the-body opts)))) +(define (sanitize-string str) + "Downcase STR and replace spaces with hyphens." + (string-map (lambda (c) + (case c + ((#\space) #\-) + (else c))) + (string-downcase str))) + (define (issue-list-item-markup-writer-action markup engine) (sxml->xml `(li (@ (class "issue-list-item")) @@ -106,7 +114,8 @@ NEW-EXTENSION." ,(markup-option markup #:title)) ,@(map (lambda (tag) (let ((words (string-split tag (char-set #\- #\space)))) - `(a (@ (href ,(string-append (%tags-path) "/" tag ".html")) + `(a (@ (href ,(string-append (%tags-path) "/" + (sanitize-string tag) ".html")) (class ,(string-append "tag" (if (not (null? (lset-intersection string=? words @@ -209,7 +218,8 @@ issue listings are not generated." (when tags-path (for-each (lambda (tag) (let ((output-file (string-append output-directory - tags-path "/" tag ".html"))) + tags-path "/" + (sanitize-string tag) ".html"))) (display (format "tag: ~a -> ~a~%" tag output-file)) (build-issue-listing (reverse (filter (lambda (issue) (member tag (issue-keywords issue))) -- cgit v1.2.3