I’ve just finished reading Typst as a Language, by Justin Pombrio.
Under § Content he writes
Typst has a lot of builtin functions from content to content. For example, underscores are a shorthand for a call to the function
emph, which (by default) italicizes the content it’s given:[example]
So
emphis a function from content to content. Notice that its argument is passed in square brackets[...]to mark the argument as markup.
From what I understand, he means that when you pass an argument inside square brackets it means that the text should be interpreted as content and not string? I.e. square brackets works similar to the dollar signs using to go into math mode, but the markup-square-brackets need to be used for giving an argument to a function?
But Justin later say under § Functions (not allowed to add > 2 links in a post) that
If you put brackets
[...]after the arguments passed to the function, the content in the brackets is passed as the function’s last positional argument.
First off, I’m a bit confused about the wording here. If you put the brackets “after the arguments passed to the function” (implicit that you have given all arguments you want to give to the function), why does the function take yet another argument if it already have received all its arguments?
I’m assuming here that he simply meant “you can give an argument as content in [...], and the content will be passed as the function’s last positional argument.”
But if that’s true, doesn’t that contradict the first thing I quoted? I’m a but confused here. It is more probable that I’ve misunderstood something, or the semantics are clear and you just have to know how many args you’ve given in square brackets, and how many not, and keep a count.
Thank you!
