diff --git a/main.rkt b/main.rkt index 848d25b..edee26e 100644 --- a/main.rkt +++ b/main.rkt @@ -1,6 +1,6 @@ #lang racket/base -(require (only-in (planet mb/pollen/tools) as-list named-xexpr? decode tee ƒ) - (only-in (planet mb/pollen/main-helper) split-metas require-extras)) +(require (planet mb/pollen/tools) + (planet mb/pollen/main-helper)) (provide (except-out (all-from-out racket/base) #%module-begin) (rename-out [module-begin #%module-begin])) @@ -22,52 +22,38 @@ ; doclang2_raw is a clone of scribble/doclang2 with decode disabled ; helpful because it collects & exports content via 'doc (module pollen-inner (planet mb/pollen/doclang2_raw) + ; use same requires as top of main.rkt + ; (can't import them from surrounding module due to submodule rules) (require (planet mb/pollen/tools) - (planet mb/pollen/template) ; for navigation functions (planet mb/pollen/main-helper)) ; for split-metas and get-here (require-and-provide-extras) ; brings in the project require files ; #%top binding catches ids that aren't defined ; here, convert them to basic xexpr ; #%top is a syntax transformer that returns a function - ; ƒ x captures all the args (vs. ƒ(x), which only catches one) + ; λ x captures all the args (vs. λ(x), which only catches one) ; and id is not spliced because it's syntax, not a true variable (define-syntax-rule (#%top . id) - (ƒ x `(id ,@x))) + (λ x `(id ,@x))) expr ... ; body of module (define inner-here here) ; set up a hook for 'here (different name to avoid macrofication) - (provide (all-defined-out)) - (provide (all-from-out ; pollen file should bring its requires - (planet mb/pollen/tools) - (planet mb/pollen/template)))) + (provide (all-defined-out))) (require 'pollen-inner) ; provides 'doc (define text (as-list doc)) ; if single line, text will be a string - (set! text (if (named-xexpr? text) ; different setup depending on whether we have - `(main ,text) ; a whole xexpr or - `(main ,@text))) ; just xexpr content + (define main (append + (merge-newlines + ; different setup depending on whether we have + (if (named-xexpr? text) + `(main ,text) ; a whole xexpr or + `(main ,@text))) ; just xexpr content + (list (meta "here" inner-here)))) ; append inner-here as meta - ; take out the metas so they don't goof up decoding - (define-values (raw-main metas) (split-metas text)) - - ; splice in any included files - ; todo: is this a safe operation? - ; assume that main will never have an attr field - ; because attr would parse out as content. - (set! raw-main (splice-xexpr-content raw-main)) - - ; decode - (define main (decode raw-main)) - - ; append metas to decoded - (when metas - (set! main (append main metas))) - - (provide main text ; module language add-ons - (except-out (all-from-out 'pollen-inner) inner-here) ; everything from user - (rename-out (inner-here here))) ; change back to 'here + (provide main) (module+ main - ((tee (ƒ(x)x) (ƒ(x)(format "named-xexpr? ~a" (named-xexpr? main)))) main)))) + (print main) + (displayln "") + (displayln (format "named-xexpr? ~a" (named-xexpr? main)))))) diff --git a/tests/pollen-lang-test.p b/tests/pollen-lang-test.p new file mode 100644 index 0000000..acd2418 --- /dev/null +++ b/tests/pollen-lang-test.p @@ -0,0 +1,7 @@ +#lang planet mb/pollen + +◊meta["metakey" "metavalue"] + +Hello world + +Goodnight moon \ No newline at end of file