From f31c92eec971a2d0a10e3ed4cc66235a86456d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 10 Aug 2020 16:44:57 +0200 Subject: HTML work. --- module/html/util.scm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 module/html/util.scm (limited to 'module/html/util.scm') diff --git a/module/html/util.scm b/module/html/util.scm new file mode 100644 index 00000000..36b1d929 --- /dev/null +++ b/module/html/util.scm @@ -0,0 +1,20 @@ +(define-module (html util) + :use-module (util)) + +;; Retuns an HTML-safe version of @var{str}. +(define-public (html-attr str) + (define cs (char-set-adjoin char-set:letter+digit #\- #\_)) + (string-filter (lambda (c) (char-set-contains? cs c)) str)) + +(define-public (date-link date) + ((@ (datetime) date->string) date "~Y-~m-~d")) + + + +;; Generate an html id for an event. +;; TODO? same event placed multiple times, when spanning multiple cells +(define-public html-id + (let ((id (make-object-property))) + (lambda (ev) + (or (id ev) + (set/r! (id ev) (symbol->string (gensym "__html_id_"))))))) -- cgit v1.2.3