So I’m using this package typst-theoretic and there’s a function (theorem) that I can pass another function (fmt-prefix) as argument.
I have several prefix styles that differ only in their color. Instead of writing a separate function for each color, I’d prefer to write a factory that takes a color and returns a prefix formatter with the required signature, e.g.
#let apply-color: color -> (prefix-with-color: text -> text) ???
#theorem(
fmt-prefix: apply-color("red"),
body: …,
solution: …,
)
I’m unsure whether Typst lets me return a function like this. Will apply-color("red") be treated as a function value, or will it run immediately and pass its result to fmt-prefix?
#let makered = text.with(red)
#makered[This text is red]
Note that even after you have applied a parameter like this, if it is a named parameter the final caller can still override it with another value, so it is very versatile that way.