(define (maprev f l)
(if (null? l)
'()
(cons (f (car l))
(maprev f (cdr l)))))
(define (tag->html tag)
(let ((name (car tag))
(attrs (cadr tag))
(content (cddr tag)))
(display "<")
(display name)
(attribute->html attrs)
(if (null? content)
(display "/>")
(begin
(display ">")
(content->html content)
(display "</")
(display name)
(display ">")))))
(define (non-closing-tag? tag-name)
(member tag-name '(area base br col command embed hr img input keygen link meta param source track wbr)))
(define (content->html content)
(if (null? content)
#t
(maprev to-html content)))
(define (to-html element)
(cond ((string? element) (display element))
((list? element) (if (symbol? (car element))
(tag->html element)
(content->html element)))
(else (display #f))))
(define (make-html tree)
(to-html tree))
(define (attribute->html attrs)
(for-each (lambda (attr)
(let ((key (car attr))
(value (cadr attr)))
(display " ")
(display key)
(display "=\"")
(display value)
(display "\"")))
attrs))