This commit is contained in:
paku 2024-10-03 14:17:16 +09:00
parent 7f276120aa
commit 53a6a8f50e

View file

@ -29,25 +29,25 @@
(or (gethash char escape-map) (or (gethash char escape-map)
char)) char))
(defun escape-string (string escape-map) (defun escape-string (str escape-map)
(if (stringp string) (if (stringp str)
(with-output-to-string (s) (with-output-to-string (out)
(loop (loop
:for c :across string :for c :across str
:do (write (escape-char c escape-map) :stream s :escape nil))) :do (write (escape-char c escape-map) :stream out :escape nil)))
string)) str))
(defun escape-html-text-content (text) (defun escape-html-text-content (str)
(escape-string text *text-content-escape-map*)) (escape-string str *text-content-escape-map*))
(defun escape-html-attribute (text) (defun escape-html-attribute (str)
(escape-string text *attribute-escape-map*)) (escape-string str *attribute-escape-map*))
(defun minify (input-string) (defun minify (str)
(with-output-to-string (out) (with-output-to-string (out)
(let ((previous-space-p nil)) (let ((previous-space-p nil))
(loop (loop
:for char :across input-string :for char :across str
:do (cond :do (cond
((whitespace-p char) ((whitespace-p char)
(unless previous-space-p (unless previous-space-p