|
|
@ -352,16 +352,21 @@
|
|
|
|
(cdata #f #f x)
|
|
|
|
(cdata #f #f x)
|
|
|
|
x))
|
|
|
|
x))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; but treat CDATA strings correctly anyhow, because that's friendly
|
|
|
|
|
|
|
|
(define (cdata-string? x)
|
|
|
|
|
|
|
|
(and (string? x) (regexp-match #rx"^<!\\[CDATA\\[.*\\]\\]>$" x) #t))
|
|
|
|
|
|
|
|
|
|
|
|
(define+provide+safe (xexpr->html x)
|
|
|
|
(define+provide+safe (xexpr->html x)
|
|
|
|
(xexpr? . -> . string?)
|
|
|
|
(xexpr? . -> . string?)
|
|
|
|
(xexpr->string
|
|
|
|
(xexpr->string
|
|
|
|
(let loop ([x x])
|
|
|
|
(let loop ([x x])
|
|
|
|
(if (txexpr? x)
|
|
|
|
(cond
|
|
|
|
|
|
|
|
[(txexpr? x)
|
|
|
|
(let*-values ([(tag attrs elements) (txexpr->values x)]
|
|
|
|
(let*-values ([(tag attrs elements) (txexpr->values x)]
|
|
|
|
[(proc) (if (memq tag '(script style))
|
|
|
|
[(proc) (if (memq tag '(script style))
|
|
|
|
->cdata
|
|
|
|
->cdata
|
|
|
|
loop)])
|
|
|
|
loop)])
|
|
|
|
;; a little faster than `txexpr` since we know the pieces are valid
|
|
|
|
;; a little faster than `txexpr` since we know the pieces are valid
|
|
|
|
(txexpr-unsafe tag attrs (map proc elements)))
|
|
|
|
(txexpr-unsafe tag attrs (map proc elements)))]
|
|
|
|
x))))
|
|
|
|
[(cdata-string? x) (->cdata x)]
|
|
|
|
|
|
|
|
[else x]))))
|
|
|
|