You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pollen/main.rkt

57 lines
2.0 KiB
Racket

#lang racket/base
11 years ago
(provide (except-out (all-from-out racket/base) #%module-begin)
11 years ago
(rename-out [new-module-begin #%module-begin]))
11 years ago
(define-syntax-rule (new-module-begin body-exprs ...)
(#%module-begin
11 years ago
;; first three lines are positional arguments
(module inner pollen/lang/doclang_raw
main-raw
(λ(x) (cdr x)) ;; chop first linebreak with cdr
()
(require pollen/main-helper pollen/top )
(require-project-require-files)
(provide (all-defined-out))
11 years ago
;; Build 'here
(define here-path (get-here-path))
(require (only-in xml xexpr->string))
(require (only-in racket/path find-relative-path))
(require (only-in pollen/file-tools ->output-path))
(require (only-in pollen/world PROJECT_ROOT))
(define (path->pnode path)
(path->string (->output-path (find-relative-path PROJECT_ROOT path))))
(define here (path->pnode here-path))
11 years ago
11 years ago
body-exprs ...)
11 years ago
(require 'inner)
11 years ago
;; function to split tag out of txexpr
(require txexpr)
11 years ago
11 years ago
;; split out the metas. Might include user-defined metas.
;; But first, append here-path and here as meta.
;; so they can be overridden by custom meta later
;; 'root is the hook for the decoder function.
;; If it's not defined elsewhere, it just hits #%top and becomes a txexpr.
11 years ago
(define one-with-everything `(root
,@(cons `(meta "here-path" ,here-path)
(cons `(meta "here" ,here)
main-raw))))
11 years ago
(define is-meta-element? (λ(x) (and (txexpr? x) (equal? 'meta (get-tag x)))))
(define-values (metas-raw main-without-metas)
(splitf-txexpr one-with-everything is-meta-element?))
11 years ago
(define meta-element-to-pair (λ(x) (cons (cadr x) (caddr x))))
(define metas (make-hash (map meta-element-to-pair metas-raw)))
(define main main-without-metas)
11 years ago
(provide (all-from-out 'inner) metas main)
11 years ago
(module+ main
11 years ago
(print main))))