Fix bug: attributes without values didn't work.

Before, it was necessary to do something like this:

  (option (@ (selected . #false) (value "any")) "any")

instead of:

  (option (@ (selected) (value "any")) "any")

Only the former is valid SXML, as far as I can tell from the SXML
specification:

  <https://dl.acm.org/doi/pdf/10.1145/571727.571736>
This commit is contained in:
Arthur A. Gleckler 2022-10-11 21:22:39 -07:00
parent 24339e51e7
commit 73875cbaf7

View file

@ -40,11 +40,11 @@
(lambda (out) (html-display-escaped-attr (display-to-string str) out)))) (lambda (out) (html-display-escaped-attr (display-to-string str) out))))
(define (html-attr->string attr) (define (html-attr->string attr)
(if (cdr attr) (if (null? (cdr attr))
(symbol->string (car attr))
(let ((val (if (pair? (cdr attr)) (cadr attr) (cdr attr)))) (let ((val (if (pair? (cdr attr)) (cadr attr) (cdr attr))))
(string-append (symbol->string (car attr)) (string-append (symbol->string (car attr))
"=\"" (html-escape-attr val) "\"")) "=\"" (html-escape-attr val) "\""))))
(symbol->string (car attr))))
(define (html-tag->string tag attrs) (define (html-tag->string tag attrs)
(let lp ((ls attrs) (res (list (symbol->string tag) "<"))) (let lp ((ls attrs) (res (list (symbol->string tag) "<")))