adjust gmi parsing to work on a port. it doesn't actually do this internally, yet, but it will soon.
This commit is contained in:
6
gmi.rkt
6
gmi.rkt
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
(provide (contract-out
|
(provide (contract-out
|
||||||
[render (-> document? void?)]
|
[render (-> document? void?)]
|
||||||
[parse (-> (listof string?) document?)]
|
[parse (-> input-port? document?)]
|
||||||
[match-link (-> document? integer? (or/c url? #f))]
|
[match-link (-> document? integer? (or/c url? #f))]
|
||||||
[struct document ((items (listof (or/c text? link? pre?))))]))
|
[struct document ((items (listof (or/c text? link? pre?))))]))
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
(car split))
|
(car split))
|
||||||
link-#))))
|
link-#))))
|
||||||
|
|
||||||
(define (parse lines)
|
(define (parse body-port)
|
||||||
(define (iter document lines state link-id)
|
(define (iter document lines state link-id)
|
||||||
;; when there are no more lines, we have finished parsing.
|
;; when there are no more lines, we have finished parsing.
|
||||||
(if (empty? lines)
|
(if (empty? lines)
|
||||||
@@ -95,7 +95,7 @@
|
|||||||
'normal
|
'normal
|
||||||
link-id)])))
|
link-id)])))
|
||||||
|
|
||||||
(document (iter (list) lines 'normal 1)))
|
(document (iter (list) (port->lines body-port) 'normal 1)))
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; RENDERING
|
;;; RENDERING
|
||||||
|
Reference in New Issue
Block a user