start firmly defining module boundaries for gmi parser
This commit is contained in:
11
gmi.rkt
11
gmi.rkt
@@ -1,9 +1,14 @@
|
|||||||
#lang racket
|
#lang racket
|
||||||
|
|
||||||
(provide parse render)
|
(provide (contract-out
|
||||||
|
[render (-> document? void?)]
|
||||||
|
[parse (-> (listof string?) document?)]
|
||||||
|
[struct document ((structure (listof (or/c text? link? pre?))))]))
|
||||||
|
|
||||||
;; a gemtext document is represented as a list of structs, a struct
|
;; a gemtext document is represented as a list of structs, a struct
|
||||||
;; for each type of item in a document.
|
;; for each type of item in a document.
|
||||||
|
(struct document (structure))
|
||||||
|
|
||||||
(struct text (str))
|
(struct text (str))
|
||||||
(struct link (url str ord))
|
(struct link (url str ord))
|
||||||
(struct pre (str))
|
(struct pre (str))
|
||||||
@@ -87,7 +92,7 @@
|
|||||||
'normal
|
'normal
|
||||||
link-#)])))
|
link-#)])))
|
||||||
|
|
||||||
(iter (list) lines 'normal 1))
|
(document (iter (list) lines 'normal 1)))
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; RENDERING
|
;;; RENDERING
|
||||||
@@ -141,4 +146,4 @@
|
|||||||
|
|
||||||
[(link? line)
|
[(link? line)
|
||||||
(printf "[~a] ~a\n" (link-ord line) (link-str line))]))
|
(printf "[~a] ~a\n" (link-ord line) (link-str line))]))
|
||||||
document))
|
(document-structure document)))
|
||||||
|
Reference in New Issue
Block a user