Rendering sequential txexprs
#158
Closed
opened 6 years ago by jlorieau
·
3 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
I'm fairly new to lisp, and I may have coded a tag rendering procedure incorrectly.
I have a css/html element that I need to format as three sequential tags. (For reference, it's the sidenote element in the Tufte CSS (see https://edwardtufte.github.io/tufte-css/)).
Effectively, I need to render a sidenote tag as three sequential sets of tags.
I can format the above into a valid
txexpr
with sequential elements---by using a list append for txexpr elements. However, pollen seems to test for individualtxexpr
elements (txexpr-element?
) when rendering in html. It seems that it could be useful to insert multiple sequential elements during processing. However, the current behavior of rendering a single element might be the desired behavior.In any case, I thought I'd post this issue, since it may be a useful bug to fix. I'd assist, but I'm still a week away from becoming a decent lisper.
(I can of course get around this by creating rending the txexpr with strings.)
Thank you for your response, and thanks for making a great software package available.
Hi @jlorieau I ran into this precise puzzler when doing my own Pollen/Tufte CSS project.
In order to be a valid
txexpr
, the expression has to be a list with a symbol in the first position, followed by an optional list of attributes and then by any number of elements (any X-expressions). As you are finding, three sequentialtxexpr
don't qualify as a single validtxexpr
.The solution is to use Pollen's
@
splicing tag.Here's the relevant snippet from my
pollen.rkt
:By wrapping the three tagged X-expressions in wrapped an
@
tag you create a single validtxexpr
. When this result gets placed into thedoc
, the@
evaporates leaving only its contents behind.Great, thanks!
FWIW this “splicing” problem also arises in ordinary Lisp / Scheme / Racket code. In that case, you would use
begin
to wrap the expressions, which allows them to behave syntactically as one S-expression, but at runtime thebegin
wrapper evaporates. The Pollen@
tag is analogous.