mbutterick / pollen-users

please use https://forums.matthewbutterick.com/c/typesetting/ instead
https://forums.matthewbutterick.com/c/typesetting/
52 stars 0 forks source link

meta-like snippets with expansion of macros? #58

Closed aalexei closed 4 years ago

aalexei commented 4 years ago

Hi, Sorry if this is an obvious question, I'm new to pollen and racket.

I want to be able to define a title and abstract snippet in a page and then use that in the page template and other pages such as an overview page. The issue is that those snippets should expand all included macros, like for math, links and formatting. Something like

◊abstract{Properties of Hilbertspace ◊m{\mathcal{H}} }

where I have ◊m defined in pollen.rkt.

I've tried the pattern above and can get the expanded expression and insert it into a template with ◊(->html (select* 'abstract doc)). That works great, but I don't know how to remove the abstract tag from the doc so ◊(->html doc) doesn't also include it on the page at the point where I defined it. How would I filter doc so certain tags and content was dropped?

The other approach I've tried is to use metas with

◊define-meta[abstract]{◊@{Properties of Hilbertspace ◊m{\mathcal{H}} }}

and inserting it with ◊(->html (decode-elements (select* 'abstract metas))) but that seems to expand only html tags such as ◊em{this}, not the ones I've defined in the pollen.rkt file.

Are either of these the right approach?

mbutterick commented 4 years ago

In your template, rather than using select, you can separate the abstract tags from the rest with splitf-txexpr. Then you can handle them separately in the HTML.

aalexei commented 4 years ago

Awesome. That worked a treat, thanks!