summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.lonestar.org>2019-04-28 12:47:39 -0400
committerDavid Thompson <dthompson@vistahigherlearning.com>2019-05-21 08:40:40 -0400
commit142006f88478622ce301f4c744592e851c3cca37 (patch)
treebcdc67925109ff2e41a45d7019fcd77af2f1c244
parente25ed2d5696077f22b4b1826590ab98112d04307 (diff)
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.
-rw-r--r--haunt/reader.scm13
1 files changed, 11 insertions, 2 deletions
diff --git a/haunt/reader.scm b/haunt/reader.scm
index 305bcee..37c390b 100644
--- a/haunt/reader.scm
+++ b/haunt/reader.scm
@@ -105,8 +105,17 @@ post."
(define (read-html-post port)
(values (read-metadata-headers port)
- (match (xml->sxml port)
- (('*TOP* sxml) sxml))))
+ (let loop ()
+ (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
(make-reader (make-file-extension-matcher "html")