No need to escape strings

This commit is contained in:
Marcus Kammer 2024-08-08 21:14:12 +02:00
parent 99b20eda7f
commit 3bcf2047c7
Signed by: marcuskammer
GPG key ID: C374817BE285268F

View file

@ -4,17 +4,17 @@
(in-package :ml-sbt/tbl) (in-package :ml-sbt/tbl)
(defun escape-cell-content (content) (defun format-cell-content (content)
(cond ((numberp content) (format nil "~,9f" content)) (if (numberp content)
((stringp content) (spinneret:escape-string content)) (format nil "~,9f" content)
(t (spinneret:escape-string (princ-to-string content))))) content))
(defun render-table-header (headers) (defun render-table-header (headers)
(spinneret:with-html (spinneret:with-html
(:thead (:thead
(:tr (:tr
(loop for header in headers (loop for header in headers
do (:th :scope "col" (:raw (escape-cell-content header)))))))) do (:th :scope "col" (format-cell-content header)))))))
(defun render-table-body (rows) (defun render-table-body (rows)
(spinneret:with-html (spinneret:with-html
@ -22,7 +22,7 @@
(loop for row in rows (loop for row in rows
do (:tr do (:tr
(loop for cell in row (loop for cell in row
do (:td (:raw (escape-cell-content cell))))))))) do (:td (escape-cell-content cell))))))))
(defun render-table (headers rows &key (class "table")) (defun render-table (headers rows &key (class "table"))
(spinneret:with-html (spinneret:with-html