|
|
|
@ -46,11 +46,15 @@
|
|
|
|
|
(define metas (make-hash (map meta-element->assoc meta-elements)))
|
|
|
|
|
(values doc-without-metas metas))
|
|
|
|
|
|
|
|
|
|
(define doc-txexpr `(placeholder-root
|
|
|
|
|
(define doc-txexpr
|
|
|
|
|
(let ([doc-raw (if (equal? reader-mode world:reader-mode-markdown)
|
|
|
|
|
(apply (compose1 (dynamic-require 'markdown 'parse-markdown) string-append) doc-raw)
|
|
|
|
|
doc-raw)])
|
|
|
|
|
`(placeholder-root
|
|
|
|
|
,@(cons (meta 'here: inner-here)
|
|
|
|
|
(cons (meta 'here-path: inner-here-path)
|
|
|
|
|
;; cdr strips initial linebreak, but make sure doc-raw isn't blank
|
|
|
|
|
(if (and (list? doc-raw) (> 0 (length doc-raw))) (cdr doc-raw) doc-raw)))))
|
|
|
|
|
(if (and (list? doc-raw) (> 0 (length doc-raw))) (cdr doc-raw) doc-raw))))))
|
|
|
|
|
|
|
|
|
|
(define-values (doc-without-metas metas) (split-metas-to-hash doc-txexpr))
|
|
|
|
|
|
|
|
|
@ -66,7 +70,7 @@
|
|
|
|
|
(cond
|
|
|
|
|
[(equal? (string->symbol here-ext) world:ptree-source-ext) world:reader-mode-ptree]
|
|
|
|
|
[(equal? (string->symbol here-ext) world:markup-source-ext) world:reader-mode-markup]
|
|
|
|
|
[(equal? (string->symbol here-ext) world:markdown-source-ext) world:reader-mode-markdown]
|
|
|
|
|
[(equal? (string->symbol here-ext) world:markdown-source-ext) 'apply-root]
|
|
|
|
|
[else world:reader-mode-preproc]))
|
|
|
|
|
reader-mode))
|
|
|
|
|
|
|
|
|
@ -77,7 +81,7 @@
|
|
|
|
|
;; 'root is the hook for the decoder function.
|
|
|
|
|
;; If it's not a defined identifier, it just hits #%top and becomes `(root ,@body ...)
|
|
|
|
|
[(equal? parser-mode world:reader-mode-markup) root]
|
|
|
|
|
[(equal? parser-mode world:reader-mode-markdown) (compose1 (λ(x) `(root ,@x)) (dynamic-require 'markdown 'parse-markdown) string-append)]
|
|
|
|
|
[(equal? parser-mode world:reader-mode-markdown) (λ xs `(root ,@xs))] ; do nothing, it's already decoded
|
|
|
|
|
;; for preprocessor output, just make a string.
|
|
|
|
|
[else (λ xs (apply string-append (map to-string xs)))])
|
|
|
|
|
(cdr doc-without-metas))) ;; cdr strips placeholder-root tag
|
|
|
|
|