Open reuleaux opened 3 years ago
So, how do I write a template.tg.p, that renders my document in exactly the same manner as my cv2.txt above:
Pollen’s default template is called fallback.txt
and you can see it here.
Ah, OK, I see - many thanks - and works like a charme.
-A
Matthew Butterick @.***> writes:
So, how do I write a template.tg.p, that renders my document in exactly the same manner as my cv2.txt above:
Pollen’s default template is called
fallback.txt
and you can see it here.
Hi,
I am relatively new to pollen, so bear with me, please.
I have a small example project, that I will present (completely) here, to illustrate my issue:
cv2.poly.pm
therein is some small sample text in pollen markup, that I want to be rendered in different output formats: It makes use of a paragraph tag (p
), and one for emphasis (em
), among others, that I am introducing.cv2.poly.pm
Now, in my pollen.rkt file (given completely below), I specify those output format:
dbk - for docbook, html txt tg - aka "tag"
And I render my small sample file to these output formats:
I understand that my sample file is handled internally as a tagged xexpr (txexpr).
And for the commonly used output formats (
html
,txt
) pollen knows how to convert themtxexpr -> html txexpr -> txt
(i.e. I dont have to provide templates:
template.html.p
,template.txt.p
myself)whereas for the new/exoctic output formats that I am introducing:
dbk
,tg
, I have to provide such templates:template.dbk.p
,template.tg.p
I give the
template.dbk.p
template here just for completeness (in case someone is interested):template.dbk.p
and my sample document gets rendered to
cv2.dbk
Likewise I can view
cv2.html
in the browser with(and the magic of rendering my cv2 txepr to html happens automatically behind the scenes):
cv2.html
Now my question is concerning the simpler step of rendering to
.tg
(aka "tag"): I want this to be rendered in the same way as rendering to.txt
is done currently:I find rendering of
cv2.txt
very useful, as I get to see the structure of my sample document as a txexprhttp://softland:8080/cv2.txt
Now I would want my
template.tg.p
to produce this very output: showing the structure of my txexpr document!But any attempt of mine:
◊(cdr doc)
,◊(apply string-append (filter string? (flatten doc)))
etc. - several lines in mytemplate.tg.p
can be uncommented / commented out - fails in this respect:template.tg.p
- none of those attempts are working for me:In the case of
◊(cdr doc)
as above, (the best) I get to see is this:http://softland:8080/cv2.tg
well that is not exactly what I want: note that there is no space between the
p
tag and its contents, or theem
tag and its contents, and would want to see parentheses, tooSo, how do I write a
template.tg.p
, that renders my document in exactly the same manner as mycv2.txt
above:this is what I want to see when viewing
http://softland:8080/cv2.tg
Maybe this is not really a pollen question, but one for racket / tgexpr (tagged xexprs did exist in Racket before Pollen, as I understand), but nevertheless I hope to get an answer here.
Note, that in my
pollen.rkt
file given below, which has several case expressions (for my different output formats), the cases(tg)
and(else)
, the latter one responsible for creating my.txt
file, are all treated exactly the same manner:(I could have removed those
(tg)
cases here, and have just relied on the behaviour of rendering the else cases, but this is not what I want in the long run: instead I intend to change the rendering of.txt
files to just output ascii text - and have succeed to do so already in another small pollen project of mine).OK, many thanks in advance, Andreas
Now my
pollen.rkt
-- needs some cleanup, but I hope to get my point across:(tg)
is treated like(else)
, and thus like(txt)
(There is also a bunch of
txt-
functions in theretxt-decode
etc. - not to be confused with the.txt
output format, however.)