about summary refs log tree commit diff stats
path: root/src/read.scm
diff options
context:
space:
mode:
authorCase Duckworth2024-06-03 16:56:30 -0500
committerCase Duckworth2024-06-03 16:56:30 -0500
commited4e86f47935994fb424c977e4123bde625ddff1 (patch)
treefa7e3b16c1e66741cef68d29e72b7e762ff2f8bd /src/read.scm
parentFix emit and read, add imports, fix makefile (diff)
downloadjimmy-ed4e86f47935994fb424c977e4123bde625ddff1.tar.gz
jimmy-ed4e86f47935994fb424c977e4123bde625ddff1.zip
Fix html/other sourcing; re-scramble Makefile
Diffstat (limited to 'src/read.scm')
-rw-r--r--src/read.scm29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/read.scm b/src/read.scm index 94708ef..1b611bb 100644 --- a/src/read.scm +++ b/src/read.scm
@@ -36,19 +36,34 @@
36 ((null? words) ; empty line 36 ((null? words) ; empty line
37 (parse-lines (cdr lines) doc)) 37 (parse-lines (cdr lines) doc))
38 ((equal? (car words) "```") ; verbatim 38 ((equal? (car words) "```") ; verbatim
39 (parse-verbatim (cdr lines) doc '())) 39 ;; Format for verbatim header:
40 ;; ``` ?html | command ...
41 ;; -- only run command on block with html output.
42 ;; other outputs process the block normally
43 ;; ``` ?!html | command ...
44 ;; -- only run command on block when *not* outputting html.
45 ;; html processes the block normally
46 ;; ``` ?:html | command ...
47 ;; -- like ?html, but ignore the block in non-html outputs.
48 ;;;; FIXME: I think this necessitates a special emit-verbatim
49 ;;;; function.
50 (parse-verbatim (cdr lines) doc '()
51 #; (if (< 1 (length words))
52 (cons 'verb (cdr words))
53 'verb)
54 'verb))
40 (else ; another line type 55 (else ; another line type
41 (apply parse-stanza lines doc '() (line-type words))))))) 56 (apply parse-stanza lines doc '() (line-type words)))))))
42 57
43(define (parse-verbatim lines doc block) 58(define (parse-verbatim lines doc block bhead)
44 (define (close-verbatim) (cons (cons 'verb (reverse block)) doc)) 59 (define (close-verbatim) (cons (cons bhead (reverse block)) doc))
45 (cond 60 (cond
46 ((null? lines) ; end of document 61 ((null? lines) ; end of document
47 (parse-lines lines (close-verbatim))) 62 (parse-lines lines (close-verbatim)))
48 ((equal? (car lines) "```") ; end of verbatim block 63 ((equal? (car lines) "```") ; end of verbatim block
49 (parse-lines (cdr lines) (close-verbatim))) 64 (parse-lines (cdr lines) (close-verbatim)))
50 (else ; verbatim block continues 65 (else ; verbatim block continues
51 (parse-verbatim (cdr lines) doc (cons (list (car lines)) block))))) 66 (parse-verbatim (cdr lines) doc (cons (list (car lines)) block) bhead))))
52 67
53(define (parse-stanza lines doc stanza st-type 68(define (parse-stanza lines doc stanza st-type
54 #!optional (st-inlines '()) (st-words cdr)) 69 #!optional (st-inlines '()) (st-words cdr))