One source file → multiple outputs of same type? #122

Closed
opened 2 years ago by jaybonthius · 6 comments
jaybonthius commented 2 years ago (Migrated from github.com)

I know I can have multiple poly-targets, like html, txt, ltx pdf, but can I have multiple poly-targets of the same type?

My use case: I'm writing lecture notes and I would like to add a second html poly-target for some sort of javascript browser slideshow.

I'm hoping for the following: a single source file lecture.poly.pm is rendered as two separate html files: lecture-doc.html, lecture-slides.html, each processed through their own separate branches of tag functions.

Is that doable?

In the same vein, I see a similar use case with pdf: exam.poly.pm renders into exam.pdf and exam-solutions.pdf, where in the latter, solutions are made visible.

I know I can have multiple poly-targets, like `html`, `txt`, `ltx pdf`, but can I have multiple poly-targets _of the same type?_ My use case: I'm writing lecture notes and I would like to add a second `html` poly-target for some sort of javascript browser slideshow. I'm hoping for the following: a single source file `lecture.poly.pm` is rendered as two separate `html` files: `lecture-doc.html`, `lecture-slides.html`, each processed through their own separate branches of tag functions. Is that doable? In the same vein, I see a similar use case with `pdf`: `exam.poly.pm` renders into `exam.pdf` and `exam-solutions.pdf`, where in the latter, solutions are made visible.
bdeket commented 2 years ago (Migrated from github.com)

As a work-around I once did this with htm and html as different targets. But in general, I think you can make the targets doc.html, slides.html, default.pdf and solutions.pdf. (resulting in exam.default.pdf etc.)

As a work-around I once did this with `htm` and `html` as different targets. But in general, I think you can make the targets `doc.html`, `slides.html`, `default.pdf` and `solutions.pdf`. (resulting in `exam.default.pdf` etc.)
otherjoel commented 2 years ago (Migrated from github.com)

The reverse use case (many source files → one output file) came up recently, and the answer is much the same (see the second point in this comment). Thanks to the fact that Pollen sources are also Racket modules, whatever you need can be done by just writing your own code rather than depending solely on Pollen’s built-in command line tools.

The simplest hack I would try, given your “each processed through their own separate branches of tag functions” requirement, is to have html_l and html_s output targets, and then rename all the resulting files to .html with a shell script. But eventually you may find that you want to create your own Racket program that just builds everything you need in one go.

The reverse use case (many source files → one output file) came up recently, and the answer is much the same (see the second point in [this comment](https://github.com/mbutterick/pollen/issues/267#issuecomment-1002671823)). Thanks to the fact that Pollen sources are also Racket modules, whatever you need can be done by just writing your own code rather than depending solely on Pollen’s built-in command line tools. The simplest hack I would try, given your “each processed through their own separate branches of tag functions” requirement, is to have `html_l` and `html_s` output targets, and then rename all the resulting files to `.html` with a shell script. But eventually you may find that you want to create your own Racket program that just builds everything you need in one go.
jaybonthius commented 2 years ago (Migrated from github.com)

Those sound like great solutions until I work up the courage to implement a Racket-based mechanism. Thank you, Joel and @bdeket!

Those sound like great solutions until I work up the courage to implement a Racket-based mechanism. Thank you, Joel and @bdeket!
mbutterick commented 2 years ago (Migrated from github.com)

I handle situations like this by using the POLLEN environment variable.

I handle situations like this by using the [`POLLEN` environment variable](https://docs.racket-lang.org/pollen/raco-pollen.html#%28part._.The_.P.O.L.L.E.N_environment_variable%29).
mbutterick commented 2 years ago (Migrated from github.com)

This is how typographyforlawyers.com and practicaltypography.com are generated from a single set of source files. Most of the text is shared. But then I have tag functions that show or hide certain text based on the status of an environment variable.* Then everything else is the same (templates, etc.)

* Strictly speaking, POLLEN is automatically supported, but you can use any environment variable and then add it to envvar-watchlist so it cooperates with the caching system.

This is how typographyforlawyers.com and practicaltypography.com are generated from a single set of source files. Most of the text is shared. But then I have tag functions that show or hide certain text based on the status of an environment variable.* Then everything else is the same (templates, etc.) * Strictly speaking, `POLLEN` is automatically supported, but you can use any environment variable and then add it to `envvar-watchlist` so it cooperates with the caching system.
jaybonthius commented 2 years ago (Migrated from github.com)

Ah, that's a cool solution. I was wondering how you managed both sites from one set of sources. Thanks for the tip!

Ah, that's a cool solution. I was wondering how you managed both sites from one set of sources. Thanks for the tip!
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#122
Loading…
There is no content yet.