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