diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-10 16:44:57 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-10 16:44:57 +0200 |
commit | f31c92eec971a2d0a10e3ed4cc66235a86456d4a (patch) | |
tree | dc7d62019da412af2119ba46a30b6b9b4350a543 /module/html/util.scm | |
parent | Start breaking apart HTML modules. (diff) | |
download | calp-f31c92eec971a2d0a10e3ed4cc66235a86456d4a.tar.gz calp-f31c92eec971a2d0a10e3ed4cc66235a86456d4a.tar.xz |
HTML work.
Diffstat (limited to 'module/html/util.scm')
-rw-r--r-- | module/html/util.scm | 20 |
1 files changed, 20 insertions, 0 deletions
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_"))))))) |