reverse document and preformatted structures at end of parsing of each so that the document structure is in logical order
This commit is contained in:
11
gem300.rkt
11
gem300.rkt
@@ -26,7 +26,8 @@
|
|||||||
(define (iter document lines state)
|
(define (iter document lines state)
|
||||||
;; 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)
|
||||||
document
|
;; consing inherently makes everything backwards
|
||||||
|
(reverse document)
|
||||||
|
|
||||||
;; otherwise, we have a state machine to traverse.
|
;; otherwise, we have a state machine to traverse.
|
||||||
(cond
|
(cond
|
||||||
@@ -35,7 +36,13 @@
|
|||||||
(or (empty? (cdr lines))
|
(or (empty? (cdr lines))
|
||||||
(string-prefix? (car lines) "```")))
|
(string-prefix? (car lines) "```")))
|
||||||
|
|
||||||
(iter document
|
;; also hard to follow. at this point:
|
||||||
|
;; 1. the car of the document is necessarily a preformatted block
|
||||||
|
;; and the contents of that block are backwards
|
||||||
|
;; 2. take those contents, reverse them, append them to the
|
||||||
|
;; cdr of the document
|
||||||
|
(iter (cons (preformatted (reverse (preformatted-str (car document))))
|
||||||
|
document)
|
||||||
(cdr lines)
|
(cdr lines)
|
||||||
'normal)]
|
'normal)]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user