--- spiffy-base.scm 2006-12-31 23:59:52.000000000 +0800 +++ spiffy-base-new.scm 2007-01-01 00:00:23.000000000 +0800 @@ -504,21 +504,35 @@ ;;; SXML stuff: +;; These elements use the minimized close tag form; all others will +;; have an explicit close tag. +(define xhtml-empty-elements '(base meta link hr br param img area input col)) +;; These open tags will not have a newline prefixed, so as not to +;; introduce extraneous whitespace. +(define xhtml-inline-elements + '(a abbr acronym cite code dfn em font kbd q samp strong var + b big i small strike sub sup tt u blink span)) + (define (write-sxml sxml . port) (let ([port (:optional port (current-output-port))]) (let rec ([sxml sxml]) (match sxml [(tag ('@ . attrs) . data) - (fprintf port "~%<~A" tag) + (if (memq tag xhtml-inline-elements) + (fprintf port "<~A" tag) + (fprintf port "~%<~A" tag)) (for-each (match-lambda [(name val) (fprintf port " ~A=~S" name (htmlize val))] [(name) (fprintf port " ~A=~S" name name)] [a (error "invalid SXML attribute syntax" a)] ) attrs) - (write-char #\> port) - (for-each rec data) - (fprintf port "" tag) ] + (if (and (null? data) (memq tag xhtml-empty-elements)) + (fprintf port " />") + (begin + (write-char #\> port) + (for-each rec data) + (fprintf port "" tag)))] [(tag . data) (rec `(,tag (@) . ,data))] [_ (display (htmlize (with-output-to-string (cut display sxml))) port)] ) ) ) )