no title added by anonymous on Thu Nov 8 14:57:12 2012

$ more helveticard.widget.scm 
; Helveticard playing card widget.
; Based on http://zachwaugh.com/helveticards/index.html
(markup . (let* ((ranks
                   '((two   . ("2"  (top_center bottom_center)))
                     (three . ("3"  (top_center middle_center bottom_center)))
                     (four  . ("4"  (top_left top_right bottom_left bottom_right)))
                     (five  . ("5"  (top_left top_right middle_center bottom_left
                                              bottom_right)))
                     (six   . ("6"  (top_left top_right middle_left middle_right
                                              bottom_left bottom_right)))
                     (seven . ("7"  (top_left top_right middle_left middle_top
                                              middle_right bottom_left bottom_right)))
                     (eight . ("8"  (top_left top_right middle_left middle_top
                                              middle_right middle_bottom bottom_left
                                              bottom_right)))
                     (nine  . ("9"  (top_left top_right middle_top_left middle_center
                                              middle_top_right bottom_left bottom_right
                                              middle_bottom_left middle_bottom_right)))
                     (ten   . ("10" (top_left top_right middle_top_left middle_top_center
                                              middle_top_right bottom_left bottom_right
                                              middle_bottom_center middle_bottom_left
                                              middle_bottom_right)))
                     (jack  . ("J"  (middle_center)))
                     (queen . ("Q"  (middle_center)))
                     (king  . ("K"  (middle_center)))
                     (ace   . ("A"  (middle_center)))))
                 (suits '((clubs    . (& "#9827"))
                          (diamonds . (& "#9830"))
                          (spades   . (& "#9824"))
                          (hearts   . (& "#9829"))))
                 (glyphs (caddr (or (assq rank ranks) `(_ _ (middle_center)))))
                 (glyph (cdr (or (assq suit suits) `(_ "?"))))
                 (number (cadr (or (assq rank ranks) `(_ "!" _)))))
        `(div (@ (class "card " ,suit " " ,rank) ,(if name `(id ,name) '()))
              (div (@ (class "corner top"))
                   (span (@ (class "number")) ,number)
                   (span ,glyph))
              ,(map (lambda (position)
                      `(span (@ (class "suit " ,position)) ,glyph))
                    glyphs)
              (div (@ (class "corner bottom"))
                   (span (@ (class "number")) ,number)
                   (span ,glyph)))))

(attributes . ((suit spade)
               (rank ace)
               (name #f)))