beginner questions
#18
Open
opened 5 years ago by hendrikboom3
·
19 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?
(1) It looks as if document structure and design is pretty much a do-it-yourself thing with pollen. But I suspect there are a number of pre-built lozenge commands that are available, whether as part of the pollen distribution or some kind of community folklore. Is there a list of these?
(2) One feature I need is file inclusion. Ideally something like ◊include["filename"] to include another file as if its contents were present in the place of the lozenge command. I've tinkered with scribble and not succeeded. In particular I've been unable to get all its at-commands (succh as @(require ...) working reliably from included text. More seems to be involved there than merely calling elem to to necessary conversions after the at-reader has done its work.
I hope it's simpler in pollen.
(I would not mind a restriction that the syntax be properly nested. I have no need to match an open bracket in one file with a close bracket in another, and would appreciate an error message if I seem to be trying that!)
(3) Not as essential, but would be nice: using the markdown parser on part of a document. Something like:
ordinary pollen stuff
◊markdown{ a page or two of markdown-style bullet-point notation }
more ordinary pollen stuff.
(4) Is there a way to indicate that the output file should be somewhere other than in its default location; e.g., in another directory?
-- hendrik
History has taught me that it’s difficult to answer these questions in the abstract. It would be better for you to post a concrete example of something that doesn’t work the way you expect.
Mostly, Pollen is a more convenient way of writing Racket programs that process a lot of text, using X-expressions as the medium of exchange. Some people like it better than Scribble; some people don’t 😉
Here’s a working example for your second question. Every Pollen document
provide
s two values, adoc
and ametas
, which you can fetch withget-doc
andget-metas
.So we can write an
include
tag/function that gets thedoc
from another file. This will be an X-expression that starts with'(root ...)
, so I usedcdr
, unquote-splicing and the@
splicing function to lift its elements into the surrounding X-expression (in the "calling" doc).pollen.rkt
:other-file.html.pm
:index.html.pm
Saving all of these in the same folder and "running"
index.html.pm
in DrRacket results in:Thanks for the working example. It works. And seems a lot simpler than anything similar I've found in Scribble. And it puts the included text exactly where I include it. The closest thing in Scribble creates a formal subsection and moves it to the end, which is one thing I do not need or want.
It does seem to demand that I place a #lang pollen at the start of the included file.
I had to make one change: if the stuff from the included file ends up being just one string, and not a list, the cdr fails; instead I have to wrap to make the cdr succeed. I'm guessing that in this case it leaves out the call to root? Is this a bug or a feature?
Hmmm. Why would it do that? I'll have to try an included file with some losenges in it do see if it's any different.
Lots of missing information here. As Matthew said earlier, the best way for us to help is if you can provide a concrete example of something that does not work they way you expect.
Another thing I always recommend to people: work through the [four tutorials][1] in the Pollen docs — actually type out and run the examples in DrRacket. Even if you think you can understand the concepts just by reading.
Regarding your 4th question in your original post, you may be interested to read this discussion on the old Google groups list.
The approach would be to use the
markdown
package to parse the markdown inside a tag function, and then optionally re-run the resulting x-expression through the existing tag functions.So pollen uses the Racket module mechanism to include files, and so they have to be Racket modules. Does that mean that it's possible to include a Scribble module into a Pollen file? I suspect not; I suspect there will be incompatibilities.
Regarding the fourth question. The markdown package you refer me to describes a function parse-markdown. But it takes a path or a string as argument, but doesn't a lozenge-function instead receive a list of x-expressions?
Per the docs:
So if a Scribble module can be made to do
(provide doc metas)
withdoc
being an x-expression andmetas
being a hash table, then it can be treated like any other source within a Pollen project. But just like any other Pollen source, you'll have to write code to handle the x-expression you receive and transform it into your target format.There is no such thing as a lozenge-function. The lozenge is just how you signal to Pollen that what follows should be interpreted as Racket code instead of as literal text.
Further, a string is a valid x-expression.
Regarding the fourth question. The markdown package you refer me to describes a function parse-markdown. But it takes a path or a string as argument, but doesn't a lozenge-function instead receive a list of x-expressions?
Result:
About the include function you provided. It seems to require that the returned
doc
value be a pair.But sometimes it isn't. Is this a bug or a feature? And if a bug, is it a bug in pollen or a bug in
include
?Here's the case I'm having trouble with. The included file,
wiko.mt3
, is truly trivial:I get the error message
etc. etc.
The problem seems to be that the value of doc that's returned is just a string, and not
root
consed onto the beginning of anything. Evidently the running example you provide is too complex to trigger this problem.For completeness, the including file:
and the pollen.rkt file:
Try renaming wiko.mt3 to wiki.html.p?
On Fri, Nov 8, 2019, 8:43 AM hendrikboom3 notifications@github.com wrote:
I meant wiko.html.pm. Sorry for the error. I was typing this on my phone.
On Fri, Nov 8, 2019, 9:42 AM Sorawee Porncharoenwase <
sorawee.pwase@gmail.com> wrote:
Yes. renaming the file worked. The naming of files has become a black art.
I thought the #lang line would suffice to tell pollen how to read it. Evidently not.
Again, read the docs thoroughly, they are really helpful.
File Formats
There isn’t really defined behavior for what happens when you use random file extensions. If you aren't going to use the default file extensions, you should change the appropriate parameters to reflect your choices.
To supplement @otherjoel’s answer: your question about file naming is also addressed in the first tutorial and emphasized with the warning Don’t skip this section! It explains an essential Pollen concept. (It is not the only section so labeled.)
I can guarantee that if you insist on learning Pollen by avoiding these essential concepts, then yes, everything will seem like “black art”, I’m afraid.
Yes. renaming the file worked. The naming of files has become a black art.
I thought the #lang line would suffice to tell pollen how to read it. Evidently not.
I had read the section about file names, but I did not realize that it applied to the files I included, since the source file were fully identified in the ◊include request and all decisions as to source format and object format has already been made based on the name of the main source and object file. It's not as if I was asking it to make linked output files, each in a different output format.
As for the extensions I was using, they were already there in the files I was trying to convert to pollen.