#Named arguments, positional arguments and content, who is who?
1 messages · Page 1 of 1 (latest)
like this, or did you have something else in mind? #let my-fun(dest, label: none) = {...}
I have it like this but it complains whenever I do something like #path("path/to/myfile.txt")[myfile]
Throws unexpected argument at [myfile]
You can define an argument sink like this. also see https://typst.app/docs/reference/types/arguments/
?render ```rs
#let my-fun(dest, ..label) = {
dest
label.pos().at(0)
}
#my-fun("hi")[bye]
I would prefer using just an optional argument, as I test it beforehand to see if its defined
This is my function :
#let path(dest, label: none) = {
if type(label) == "none" {
label = dest
}
dest = "file:///" + dest.replace("\\", "/")
box(
fill: rgb("#eee"),
radius: 1pt,
inset: (left: 1pt, right: 3pt),
outset: (x: 0pt, y: 3pt),
emph(link(dest)[#label])
)
}```