correct logical error in gemtext parsing
This commit is contained in:
19
gem300.rkt
19
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 (empty? split)
|
||||
(text line)
|
||||
(link (car split)
|
||||
(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))))
|
||||
(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))
|
||||
|
Reference in New Issue
Block a user