diff --git a/collects/meta/web/common/extras.rkt b/collects/meta/web/common/extras.rkt index 5c835139c2..db371e79b9 100644 --- a/collects/meta/web/common/extras.rkt +++ b/collects/meta/web/common/extras.rkt @@ -10,9 +10,11 @@ ;; a div that is centered, but the text is still left-justified (provide center-div) (define (center-div . text) - (div align: 'center - (div align: 'left style: "display: inline-block;" - text))) + (let-values ([(attrs body) (split-attributes+body text)]) + (apply div align: 'center + (append attrs + (list (div align: 'left style: "display: inline-block;" + body)))))) ;; a grayish tt text (provide TT) diff --git a/collects/meta/web/html/xml.rkt b/collects/meta/web/html/xml.rkt index 09c92e0ca6..d5e0a03a68 100644 --- a/collects/meta/web/html/xml.rkt +++ b/collects/meta/web/html/xml.rkt @@ -37,6 +37,15 @@ "missing attribute value for `~s:'" a)] [else (loop (cddr xs) (cons (cons a (cadr xs)) as))])))) +;; similar, but keeps the attributes as a list, useful to build new functions +;; that accept attributes without knowing about the xml structs. +(provide split-attributes+body) +(define (split-attributes+body xs) + (let loop ([xs xs] [as '()]) + (if (and (pair? xs) (pair? (cdr xs)) (attribute->symbol (car xs))) + (loop (cddr xs) (list* (cadr xs) (car xs) as)) + (values (reverse as) xs)))) + ;; ---------------------------------------------------------------------------- ;; An output that handles xml quoting, customizable