pull/218/head
Matthew Butterick 5 years ago
parent b242eb11dc
commit 9e3a0f59e8

@ -15,8 +15,16 @@
(rename-out [pollen-module-begin #%module-begin])
(all-from-out "../core.rkt" "../setup.rkt"))
(define ((make-parse-proc parser-mode root-proc) xs)
(define (stringify xs) (apply string-append (map to-string xs)))
(define (strip-leading-newlines doc)
;; drop leading newlines, as they're often the result of `defines` and `requires`
(if (setup:trim-whitespace?)
(dropf doc (λ (ln) (member ln (list (setup:newline) ""))))
doc))
(define (stringify xs) (apply string-append (map to-string xs)))
(define (parse xs-in parser-mode root-proc)
(define xs (splice (strip-leading-newlines xs-in) (setup:splicing-tag)))
(match parser-mode
[(== default-mode-pagetree eq?) (decode-pagetree xs)]
[(== default-mode-markup eq?) (apply root-proc (remove-voids xs))]
@ -27,12 +35,6 @@
(apply root-proc xs))]
[_ (stringify xs)])) ; preprocessor mode
(define (strip-leading-newlines doc)
;; drop leading newlines, as they're often the result of `defines` and `requires`
(if (setup:trim-whitespace?)
(dropf doc (λ (ln) (member ln (list (setup:newline) ""))))
doc))
(define-syntax (pollen-module-begin stx)
(syntax-case stx ()
[(_ PARSER-MODE . EXPRS)
@ -46,14 +48,11 @@
#'(doclang:#%module-begin
DOC-ID ; positional arg for doclang-raw: name of export
(λ (xs) ; positional arg for doclang-raw: post-processor
(define proc (make-parse-proc PARSER-MODE ROOT-ID))
(define trimmed-xs (strip-leading-newlines xs))
(define doc-elements (splice trimmed-xs (setup:splicing-tag)))
(begin0
(proc doc-elements)
;; wait till the end to restore prev-metas
;; because tag functions may edit current-metas
;; and we want root to see those changes
(begin0
(parse xs PARSER-MODE ROOT-ID)
(current-metas prev-metas)))
(module METAS-ID racket/base
(provide METAS-ID)

@ -1 +1 @@
1578804970
1578891880

Loading…
Cancel
Save