From 01e79027b81ff10f501bf6289e0221e907ca460c Mon Sep 17 00:00:00 2001 From: w6vvn Date: Tue, 2 Sep 2025 08:06:55 -0700 Subject: [PATCH] correct logical error in gemtext parsing --- gem300.rkt | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/gem300.rkt b/gem300.rkt index a081006..e5a70dd 100644 --- a/gem300.rkt +++ b/gem300.rkt @@ -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))