Hopefully fix paragraph parsing
This commit is contained in:
parent
105873854c
commit
304f8839ec
1 changed files with 20 additions and 5 deletions
|
@ -212,6 +212,7 @@
|
||||||
(else (kt)))))
|
(else (kt)))))
|
||||||
(#\newline
|
(#\newline
|
||||||
;; Sure. Trailing whitespace can be any indent.
|
;; Sure. Trailing whitespace can be any indent.
|
||||||
|
(unget1 #\newline)
|
||||||
(kt))
|
(kt))
|
||||||
(#\return
|
(#\return
|
||||||
(lp n))
|
(lp n))
|
||||||
|
@ -377,6 +378,16 @@
|
||||||
(lp elts (cons (list->string chars) out))))))
|
(lp elts (cons (list->string chars) out))))))
|
||||||
((elt . elts)
|
((elt . elts)
|
||||||
(lp elts (cons elt out))))))
|
(lp elts (cons elt out))))))
|
||||||
|
(define (consume-blank-lines-then-finish kdone)
|
||||||
|
(let lp ()
|
||||||
|
(match (next)
|
||||||
|
((? eof-object?) (finish kdone))
|
||||||
|
(#\return (lp))
|
||||||
|
(#\newline
|
||||||
|
(consume-indent indent lp (lambda () (finish kdone))))
|
||||||
|
(ch
|
||||||
|
(unget1 ch)
|
||||||
|
(finish kdone)))))
|
||||||
(match (next)
|
(match (next)
|
||||||
((? eof-object?) (finish on-block-end))
|
((? eof-object?) (finish on-block-end))
|
||||||
(#\return (lp elts))
|
(#\return (lp elts))
|
||||||
|
@ -385,7 +396,7 @@
|
||||||
indent
|
indent
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(cond
|
(cond
|
||||||
((done? #\newline) => finish)
|
((done? #\newline) => consume-blank-lines-then-finish)
|
||||||
(else (lp (cons #\newline elts)))))
|
(else (lp (cons #\newline elts)))))
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(finish on-block-end))))
|
(finish on-block-end))))
|
||||||
|
@ -421,7 +432,7 @@
|
||||||
(define (done? ch)
|
(define (done? ch)
|
||||||
(match ch
|
(match ch
|
||||||
(#\newline
|
(#\newline
|
||||||
(let ((ch (next)))
|
(let lp ((ch (next)))
|
||||||
(match ch
|
(match ch
|
||||||
((? eof-object?)
|
((? eof-object?)
|
||||||
(lambda (para)
|
(lambda (para)
|
||||||
|
@ -429,9 +440,13 @@
|
||||||
(ch
|
(ch
|
||||||
(read-block-type ch #t
|
(read-block-type ch #t
|
||||||
make-continuation
|
make-continuation
|
||||||
(lambda (chars)
|
(if (eqv? ch #\newline)
|
||||||
(unget chars)
|
(lambda (chars)
|
||||||
#f))))))
|
(unget chars)
|
||||||
|
(make-continuation read-para))
|
||||||
|
(lambda (chars)
|
||||||
|
(unget chars)
|
||||||
|
#f)))))))
|
||||||
(_ #f)))
|
(_ #f)))
|
||||||
(read-text 'para indent done? (make-continuation read-block-list)))
|
(read-text 'para indent done? (make-continuation read-block-list)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue