Closed oldmankit closed 4 years ago
So you want two pagetrees that are the same, except the file extension for each pagenode is txt
rather than html
?
So you want two pagetrees that are the same, except the file extension for each pagenode is
txt
rather thanhtml
?
Yes, that's exactly right.
I suppose I’d write the pagetree using poly
extensions and then pass the tree through a tag function that converts tnem. Here’s one approach:
#lang pollen/ptree
◊(require racket/match txexpr pollen/setup racket/string)
◊(define (change-ext . xs)
(cons '@
(let loop ([x xs])
(match x
[(? list? xs) (map loop xs)]
[(? string? str) #:when (string-suffix? str ".poly")
(string-replace str ".poly" (format ".~a" (current-poly-target)))]
[(? symbol? sym) (string->symbol (loop (symbol->string sym)))]
[_ x]))))
◊change-ext{
hello.poly
◊world.poly{
this.poly
that.poly
}
}
(Taking the shortcut here of using string-manipulation functions on path-like things, which is not the most enviable practice but it shortens the example)
Thank you so much, @mbutterick That works perfectly.
I had a little flash of insight when I saw what you'd done: truly everything is programmable, even the .ptree which I was thinking of as a kind of black box.
Do pagetrees only work with one output source?
Let's say I'm using poly sources (1.poly.pm and 2.poly.pm) to generate both html and txt output. If my pagetree contains:
then Pollen functions which rely on the pagetree (for example,
previous here
) work only when generating html output. The txt output seems to be unaware that there is any pagetree. So previous, next, parent and children links don't produce anything.I tried making a pagetree with:
But that didn't fix it. None of the pagetree-depenent functions worked for either html or for txt.