ie condcoms in sxml added by retroj on Wed Jan 25 21:39:36 2012

;; http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
(define (special-html tag elems)
  (list
   #\newline
   "<!--[if lt IE 7]> <html class='lt-ie9 lt-ie8 lt-ie7'> <![endif]-->\n"
   "<!--[if IE 7]>    <html class='lt-ie9 lt-ie8'> <![endif]-->\n"
   "<!--[if IE 8]>    <html class='lt-ie9'> <![endif]-->\n"
   "<!--[if gt IE 8]><!--> "
   (if (and (pair? elems) (pair? (car elems))
            (eq? '@ (caar elems)))
       (list #\< tag (cdar elems) #\> " <!--<![endif]-->"
             (cdr elems) "</" tag #\>)
       (list #\< tag #\> " <!--<![endif]-->"
             elems "</" tag #\>))))

(push! `(html . ,special-html)
       sxml-conversion-rules)


(define (if-ie-guts conditional)
  (define (comparison? sym)
    (member sym '(< > <= >=)))
  (define (translate-comparison sym)
    (case sym
      ((<) "lt")
      ((<=) "lte")
      ((>) "gt")
      ((>=) "gte")))
  (string-join
   (match conditional
     (() '("IE"))
     (((? number? x)) (list "IE" (number->string x)))
     (((? comparison? sym) (? number? x))
      (list (translate-comparison sym) "IE" (number->string x))))
   " "))

(define (if-ie tag elems)
  `((inject "<!--[if " ,(if-ie-guts (car elems)) "]>")
    ,(cdr elems)
    (inject "<![endif]-->")))

(push! `(if-ie *macro* . ,if-ie)
       sxml-conversion-rules)