Index: code-docs/pollen.scrbl ================================================================== --- code-docs/pollen.scrbl +++ code-docs/pollen.scrbl @@ -62,10 +62,13 @@ (poly-branch-kwargs-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. @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.} Index: pollen.rkt ================================================================== --- pollen.rkt +++ pollen.rkt @@ -58,14 +58,13 @@ (with-syntax ([((POLY-TARGET POLY-FUNC) ...) (for/list ([target (in-list (setup:poly-targets))]) (list target (format-id stx "~a-~a" target #'TAG)))] [DEFAULT-FUNC (format-id stx "html-~a" #'TAG)]) #'(define-tag-function (TAG attributes elems) - (define args (cons attributes elems)) (case (current-poly-target) - [(POLY-TARGET) (apply POLY-FUNC args)] ... - [else (apply DEFAULT-FUNC args)])))])) + [(POLY-TARGET) (POLY-FUNC attributes elems)] ... + [else (DEFAULT-FUNC attributes elems)])))])) ;; Like above, but uses `define` instead of `define-tag-function`. ;; Use this when you know you will not need keyword arguments. ;; (define-syntax (poly-branch-tag stx) @@ -99,11 +98,11 @@ (poly-branch-tag smallcaps) (poly-branch-tag center) (poly-branch-tag section) (poly-branch-tag subsection) (poly-branch-tag code) -(poly-branch-tag blockcode) +(poly-branch-kwargs-tag blockcode) (poly-branch-kwargs-tag verse) ; [#:title ""] [#:italic "no"] (poly-branch-tag link) (poly-branch-tag url) (poly-branch-tag fn) Index: tags-html.rkt ================================================================== --- tags-html.rkt +++ tags-html.rkt @@ -87,11 +87,11 @@ (define html-subsection (default-tag-function 'h3)) (define html-newthought (default-tag-function 'span #:class "newthought")) (define html-smallcaps (default-tag-function 'span #:class "smallcaps")) (define html-center (default-tag-function 'div #:style "text-align: center")) -(define-tag-function (html-root attrs elements) +(define (html-root . elements) (define first-pass (decode-elements elements #:txexpr-elements-proc decode-hardwrapped-paragraphs #:exclude-tags '(script style figure table pre))) (define second-pass @@ -100,17 +100,17 @@ #:inline-txexpr-proc decode-link-urls #:string-proc (compose1 smart-quotes smart-dashes) #:exclude-tags '(script style pre code))) `(body ,@second-pass ,(html-footnote-block))) -(define-tag-function (html-blockcode attrs elems) +(define (html-blockcode attrs elems) (define file (or (assoc 'filename attrs) "")) (define codeblock `(pre [[class "code"]] (code ,@elems))) (cond [(string>? file "") `(@ (div [[class "listing-filename"]] 128196 " " ,file) ,codeblock)] [else codeblock])) -(define-tag-function (html-verse attrs elems) +(define (html-verse attrs elems) (let* ([title (or (assoc 'title attrs) "")] [italic? (assoc 'italic attrs)] [pre-attrs (cond [italic? '([class "verse"] [style "font-style: italic"])] [else '([class "verse"])])] [pre-title (cond [(string>? title "") '(p [[class "verse-heading"]] ,title)] @@ -189,7 +189,7 @@ (format "~a" (+ 1 fnref-num)))]] "↩"))]) `(li [[id ,(fndef-id fn-name)]] ,@definition-text ,@backrefs)))) (cond [(null? note-items) ""] [else `(section ((class "footnotes")) (hr) (ol ,@note-items))])) -(define-tag-function (html-note attrs elems) +(define (html-note attrs elems) (txexpr 'note attrs (decode-paragraphs elems #:force? #t)))