correct logical error in gemtext parsing

This commit is contained in:
2025-09-02 08:06:55 -07:00
parent 4a08e57d3f
commit 01e79027b8

View File

@@ -9,17 +9,12 @@
(define (parse-url line)
(let ([split (string-split (substring line 2))])
;; there are necessarily at least two elements
;; in the split (the => and the URL) otherwise
;; its just text.
(if (>= (length split) 2)
(link (second split)
;; if there are at least three elements in the split,
;; that means that everything after the URL is text.
(if (>= (length split) 3)
(string-join (drop split 2))
#f))
(text line))))
(if (empty? split)
(text line)
(link (car split)
(if (>= (length split) 2)
(string-join (cdr split))
(car split))))))
(define (gemtext-parse lines)
@@ -42,7 +37,7 @@
;; 2. take those contents, reverse them, append them to the
;; cdr of the document
(iter (cons (preformatted (reverse (preformatted-str (car document))))
document)
(cdr document))
(cdr lines)
'normal)]
@@ -80,7 +75,7 @@
(cdr lines)
'normal)])))
(displayln (iter (list) lines 'normal)))
(iter (list) lines 'normal))
(define (request url-str)
(define url (string->url url-str))