reader: html: Add support for multiple top-level elements.

Currently, if given a file containing more than one top-level elements,
'read-html-post will only return the first.
This commit is contained in:
Jakob L. Kreuze 2019-04-28 12:47:39 -04:00 committed by David Thompson
parent e25ed2d569
commit 142006f884
1 changed files with 11 additions and 2 deletions

View File

@ -105,8 +105,17 @@ post."
(define (read-html-post port) (define (read-html-post port)
(values (read-metadata-headers port) (values (read-metadata-headers port)
(match (xml->sxml port) (let loop ()
(('*TOP* sxml) sxml)))) (let ((next-char (peek-char port)))
(cond
((eof-object? next-char)
'())
((char-set-contains? char-set:whitespace next-char)
(read-char port)
(loop))
(else
(match (xml->sxml port)
(('*TOP* sxml) (cons sxml (loop))))))))))
(define html-reader (define html-reader
(make-reader (make-file-extension-matcher "html") (make-reader (make-file-extension-matcher "html")