@@ -14,63 +14,21 @@ pollen/tag pollen/setup pollen/core sugar/coerce)) -@title[#:tag "pollen-rkt"]{@filepath{pollen.rkt}} +@title[#:tag "pollen-rkt"]{Pollen} @defmodule["pollen.rkt" #:packages ()] The file @filepath{pollen.rkt} is implicitly @code{require}d in every template and every @code{#lang pollen} file in the project. It defines the markup for all Pollen documents, and also re-provides -everything provided by @code{crystalize.rkt}. +everything provided by @filepath{cache.rkt} and @filepath{crystalize.rkt}. The @code{setup} module towards the top of the file is used as described in @racketmodname[pollen/setup]. -@section{Defining new tags} - -I use a couple of macros to define tag functions that automatically branch into other functions -depending on the current output target format. This allows me to put the format-specific tag -functions in separate files that have separate places in the dependency chain. So if only the HTML -tag functions have changed and not those for PDF, the makefile can ensure only the HTML files are -rebuilt. - -@defproc[#:kind "syntax" - (poly-branch-tag (tag-id symbol?)) - (-> txexpr?)] - -Defines a new function @racket[_tag-id] which will automatically pass all of its arguments to a -function whose name is the value returned by @racket[current-poly-target], followed by a hyphen, -followed by @racket[_tag]. So whenever the current output format is @racket['html], the function -defined by @racket[(poly-branch-tag _p)] will branch to a function named @racket[html-p]; when the -current format is @racket['pdf], it will branch to @racket[pdf-p], and so forth. - -You @emph{must} define these branch functions separately, and you must define one for @emph{every} -output format included in the definition of @racket[poly-targets] in this file’s @racket[setup] -submodule. If you do not, you will get “unbound identifier” errors at expansion time. - -The convention in this project is to define and provide these branch functions in separate files: -see, e.g., @filepath{tags-html.rkt}. - -Functions defined with this macro @emph{do not} accept keyword arguments. If you need keyword -arguments, see @racket[poly-branch-kwargs-tag]. - -@margin-note{The thought behind having two macros so similar is that, by cutting out handling for keyword -arguments, @racket[poly-branch-tag] could produce simpler and faster code. I have not verified if -this intuition is meaningful or correct.} - -@defproc[#:kind "syntax" - (poly-branch-kwargs-tag (tag-id symbol?)) - (-> txexpr?)] - -Works just like @racket[poly-branch-tag], but uses Pollen’s @racket[define-tag-function] so that -keyword arguments will automatically be parsed as X-expression attributes. - -Additionally, the branch functions called from the new function must accept exactly two arguments: -a list of attributes and a list of elements. - @section{Markup reference} These are the tags that can be used in any of @italic{The Local Yarn}’s Pollen documents (articles, etc). @@ -295,5 +253,47 @@ ◊for/s[x '(7 8 9)]{Now once for number ◊x} ◊;Above line is shorthand for this one: ◊for/splice[[(x (in-list '(7 8 9)))]]{Now once for number ◊x} }| + +@section{Defining new tags} + +I use a couple of macros to define tag functions that automatically branch into other functions +depending on the current output target format. This allows me to put the format-specific tag +functions in separate files that have separate places in the dependency chain. So if only the HTML +tag functions have changed and not those for PDF, the @filepath{makefile} can ensure only the HTML files are +rebuilt. + +@defproc[#:kind "syntax" + (poly-branch-tag (tag-id symbol?)) + (-> txexpr?)] + +Defines a new function @racket[_tag-id] which will automatically pass all of its arguments to a +function whose name is the value returned by @racket[current-poly-target], followed by a hyphen, +followed by @racket[_tag]. So whenever the current output format is @racket['html], the function +defined by @racket[(poly-branch-tag _p)] will branch to a function named @racket[html-p]; when the +current format is @racket['pdf], it will branch to @racket[pdf-p], and so forth. + +You @emph{must} define these branch functions separately, and you must define one for @emph{every} +output format included in the definition of @racket[poly-targets] in this file’s @racket[setup] +submodule. If you do not, you will get “unbound identifier” errors at expansion time. + +The convention in this project is to define and provide these branch functions in separate files: +see, e.g., @filepath{tags-html.rkt}. + +Functions defined with this macro @emph{do not} accept keyword arguments. If you need keyword +arguments, see @racket[poly-branch-kwargs-tag]. + +@margin-note{The thought behind having two macros so similar is that, by cutting out handling for keyword +arguments, @racket[poly-branch-tag] could produce simpler and faster code. I have not verified if +this intuition is meaningful or correct.} + +@defproc[#:kind "syntax" + (poly-branch-kwargs-tag (tag-id symbol?)) + (-> txexpr?)] + +Works just like @racket[poly-branch-tag], but uses Pollen’s @racket[define-tag-function] so that +keyword arguments will automatically be parsed as X-expression attributes. + +Additionally, the branch functions called from the new function must accept exactly two arguments: +a list of attributes and a list of elements.