Avoid calling display when processing sxml

As I think this could cause suspendable ports issues.
This commit is contained in:
Christopher Baines 2025-06-19 09:53:06 +01:00
parent 9f431462db
commit a75c998739

View file

@ -29,6 +29,7 @@
#:use-module (ice-9 match)
#:use-module (ice-9 format)
#:use-module (ice-9 hash-table)
#:use-module (ice-9 textual-ports)
#:export (sxml->html))
(define %self-closing-tags
@ -310,7 +311,7 @@
(let ((escaped (hash-ref %escape-chars c)))
(if escaped
(format port "&~a;" escaped)
(display c port))))
(put-char port c))))
(string-for-each escape s))
(define (object->escaped-html obj port)
@ -329,7 +330,7 @@
"Write ATTR and VALUE to PORT."
(format port "~a=\"" attr)
(attribute-value->html value port)
(display #\" port))
(put-char port #\"))
(define (element->html tag attrs body port)
"Write the HTML TAG to PORT, where TAG has the attributes in the
@ -337,13 +338,13 @@ list ATTRS and the child nodes in BODY."
(format port "<~a" tag)
(for-each (match-lambda
((attr value)
(display #\space port)
(put-char port #\space)
(attribute->html attr value port)))
attrs)
(if (and (null? body) (self-closing-tag? tag))
(display " />" port)
(put-string port " />")
(begin
(display #\> port)
(put-char port #\>)
(for-each (cut sxml->html <> port) body)
(format port "</~a>" tag))))
@ -358,7 +359,7 @@ list ATTRS and the child nodes in BODY."
(doctype->html type port))
;; Unescaped, raw HTML output
(('raw html)
(display html port))
(put-string port html))
(('*ENTITY* name)
(simple-format port "&~A;" name))
(((? symbol? tag) ('@ attrs ...) body ...)