multiple text arguments?
#116
Open
opened 3 years ago by aalexei
·
5 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?
Hi, I'm wanting to use Pollen to generate math-heavy material for a website. It seems that the best way to do this at the moment is to keep the maths in LaTeX using KaTeX to generate the maths output and everything else is written in Pollen. I have this working ok, but I'm tripping up on how to nicely convert some LaTeX macros to Pollen. I'd rather have minimal inclusion of LaTeX as a 'necessary evil' and the majority of the coding occurring in Pollen/Racket than having two systems to debug.
LaTeX allows for macros to have multiple arguments like:
While I can do something like:
It looks ugly in text since you have to use strings:
Is it possible to write a pollen function with multiple text parts, something like the following?
It's not possible with Scribble's reader (which is what Pollen is based on), but you can kinda simulate it by doing something like:
I guess it's also possible to add extra control characters:
so that the following works (where "│" is a unicode character unlikely to appear in tex)
This form would be easily extendable to any number of arguments including a variable length lists, for things like tables and matrices.
Ok, need something more sophisticated if the arguments can have nested expressions
Though you can only have one pair of curly braces in each expression, you can nest subexpressions (each with their own curly braces) as deep as you want, e.g. —
Thanks for the responses! Here's something closer to what I had in mind:
First a method to split lists at a marker (from https://codereview.stackexchange.com/a/87626)
Use a pollen variable set to a symbol so it gets tokenized as a separate element and we don't have to search within strings and possibly have to break them apart.
So it's possible to write
which is about as terse as the macro in latex and it will parse arbitrary text expression for each argument. Easy to extend too, even for variable-length 'arguments' like for a table where the cells can contain any text or pollen commands:
e.g.