How should I make a pagetree with poly sources? #23

Closed
opened 4 years ago by oldmankit · 4 comments
oldmankit commented 4 years ago (Migrated from github.com)

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:

  • 1.html
  • 2.html

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:

  • 1.poly
  • 2.poly

But that didn't fix it. None of the pagetree-depenent functions worked for either html or for txt.

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: - 1.html - 2.html 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: - 1.poly - 2.poly But that didn't fix it. None of the pagetree-depenent functions worked for either html or for txt.
mbutterick commented 4 years ago (Migrated from github.com)

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 than `html`?
oldmankit commented 4 years ago (Migrated from github.com)

So you want two pagetrees that are the same, except the file extension for each pagenode is txt rather than html?

Yes, that's exactly right.

> So you want two pagetrees that are the same, except the file extension for each pagenode is `txt` rather than `html`? Yes, that's exactly right.
mbutterick commented 4 years ago (Migrated from github.com)

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)

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)
oldmankit commented 4 years ago (Migrated from github.com)

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.

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.
This repo is archived. You cannot comment on issues.
No Milestone
No project
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen-users#23
Loading…
There is no content yet.