1 (define-module (skribe-utils)
2 #:use-module
(ice-9 match
) ; match-lambda
3 #:use-module
(srfi srfi-1
) ; list stuff
13 (define (email address
)
14 "Obfuscate a given email ADDRESS."
15 `(span (@ (class "obfuscated"))
16 ,(string-map (lambda (c) (integer->char
(+ 1 (char->integer c
))))
26 (define* (table #:key
(align '()) headers rows
)
27 "Build HTML tables more easily."
28 (let ((alignment (append align
29 (make-list (- (length headers
)
32 (define (make-row fields
)
33 `(tr ,(map (match-lambda
35 `(td (@ (align ,alignment
)) ,field
)))
36 (zip fields alignment
))))
37 (define (make-header fields
)
38 `(tr (@ (class "header"))
41 `(th (@ (align ,alignment
)) ,field
)))
42 (zip fields alignment
))))
44 (thead ,(make-header headers
))
45 (tbody ,(map make-row rows
)))))
47 (define (lyrics . contents
)
48 `(pre (@ (class "lyrics")) ,contents
))
50 (define (ref url text
)
51 `(a (@ (href ,url
)) ,text
))
53 (define (figure file caption
)
54 `(div (@ (class "figure"))
55 (img (@ (src ,(if (string-prefix?
"/" file
)
57 (string-append "/images/posts/" file
)))
59 (p (@ (class "caption")) ,caption
)))
61 (define (wide-img file alt
)
62 `(img (@ (class "full stretch")
63 (src ,(if (string-prefix?
"/" file
)
65 (string-append "/images/posts/" file
)))