tiny refac

pull/175/head
Matthew Butterick 7 years ago
parent f2238189d7
commit de9436a695

@ -5,17 +5,18 @@
(provide (except-out (all-from-out racket/base) #%module-begin) (provide (except-out (all-from-out racket/base) #%module-begin)
(rename-out [pollen-module-begin #%module-begin])) (rename-out [pollen-module-begin #%module-begin]))
(define (make-parse-proc parser-mode root-proc)
(define ((make-parse-proc parser-mode root-proc) xs)
(define (stringify xs) (apply string-append (map to-string xs))) (define (stringify xs) (apply string-append (map to-string xs)))
(cond (cond
[(eq? parser-mode default-mode-pagetree) decode-pagetree] [(eq? parser-mode default-mode-pagetree) (decode-pagetree xs)]
[(eq? parser-mode default-mode-markup) (λ (xs) (apply root-proc (remove-voids xs)))] [(eq? parser-mode default-mode-markup) (apply root-proc (remove-voids xs))]
[(eq? parser-mode default-mode-markdown) [(eq? parser-mode default-mode-markdown)
(λ (xs) (let* ([xs (stringify xs)] (let* ([xs (stringify xs)]
[xs ((dynamic-require 'markdown 'parse-markdown) xs)] [xs ((dynamic-require 'markdown 'parse-markdown) xs)]
[xs (map strip-empty-attrs xs)]) [xs (map strip-empty-attrs xs)])
(apply root-proc xs)))] (apply root-proc xs))]
[else stringify])) ; preprocessor mode [else (stringify xs)])) ; preprocessor mode
(define (strip-leading-newlines doc) (define (strip-leading-newlines doc)
@ -23,11 +24,11 @@
(or (memf (λ (ln) (and (not (equal? ln (setup:newline))) (or (memf (λ (ln) (and (not (equal? ln (setup:newline)))
(not (equal? ln "")))) doc) null)) (not (equal? ln "")))) doc) null))
(define-syntax (pollen-module-begin stx) (define-syntax (pollen-module-begin stx)
(syntax-case stx () (syntax-case stx ()
[(_ PARSER-MODE . EXPRS) [(_ PARSER-MODE . EXPRS)
(with-syntax (;; 'parser-mode-from-reader will be #f for an inline submodule (with-syntax ([EXPRS (replace-context #'here #'EXPRS)]
[EXPRS (replace-context #'here #'EXPRS)]
[META-HASH (split-metas #'EXPRS (setup:define-meta-name))] [META-HASH (split-metas #'EXPRS (setup:define-meta-name))]
[METAS-ID (setup:meta-export)] [METAS-ID (setup:meta-export)]
[META-MOD-ID (setup:meta-export)] [META-MOD-ID (setup:meta-export)]

@ -1 +1 @@
1524676723 1524762793

Loading…
Cancel
Save