(defun write-as-html (string &key (stream t) (escape-whitespace nil)) (loop for char across string do (cond ((char= char #\Space) (if escape-whitespace (princ " " stream) (write-char char stream))) ((gethash char *html-entites*) (princ (gethash char *html-entites*) stream)) (t (write-char char stream)))))Source Context