allow current-metas to be edited by tag functions

pull/218/head
Matthew Butterick 5 years ago
parent f9c47ef953
commit 4f4dc34850

@ -45,12 +45,16 @@
[ALL-DEFINED-OUT (datum->syntax #'EXPRS '(all-defined-out))]) [ALL-DEFINED-OUT (datum->syntax #'EXPRS '(all-defined-out))])
#'(doclang:#%module-begin #'(doclang:#%module-begin
DOC-ID ; positional arg for doclang-raw: name of export DOC-ID ; positional arg for doclang-raw: name of export
(λ (xs) (λ (xs) ; positional arg for doclang-raw: post-processor
(define proc (make-parse-proc PARSER-MODE ROOT-ID)) (define proc (make-parse-proc PARSER-MODE ROOT-ID))
(define trimmed-xs (strip-leading-newlines xs)) (define trimmed-xs (strip-leading-newlines xs))
(define doc-elements (splice trimmed-xs (setup:splicing-tag))) (define doc-elements (splice trimmed-xs (setup:splicing-tag)))
(parameterize ([current-metas METAS-ID-CALLER]) (begin0
(proc doc-elements))) ; positional arg for doclang-raw: post-processor (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
(current-metas prev-metas)))
(module METAS-ID racket/base (module METAS-ID racket/base
(provide METAS-ID) (provide METAS-ID)
(define METAS-ID META-HASH)) (define METAS-ID META-HASH))
@ -60,5 +64,6 @@
(define prev-metas (current-metas)) (define prev-metas (current-metas))
(define METAS-ID-CALLER METAS-ID) (define METAS-ID-CALLER METAS-ID)
(and (current-metas METAS-ID) "") ; because empty strings get stripped, voids don't (and (current-metas METAS-ID) "") ; because empty strings get stripped, voids don't
(begin . EXPRS) ;; we set current-metas imperatively rather than using `splicing-parameterize`
(and (current-metas prev-metas) "")))])) ; leave behind empty string, not void ;; so that we can unset it in the post processor, rather than out here
(begin . EXPRS)))]))

@ -1 +1 @@
1578696312 1578696364

Loading…
Cancel
Save