How to pass formatted markup to a string argument?

When a package expects a string argument, what is the easiest way to supply it with a string that has e.g. italics in it? Entering [blah _blah_ blah] does not work, since this is content instead of a string…

What exactly do you mean by “a string that has italics in it” ?
Do you mean like "blah _blah_ blah" ? In which case it is simply a string, the underscores only have a special meaning in content or math mode

So I suppose I am asking, is there a way to format a string to have italics? I.e. is there some string formatting escape command that converts “blah blah” into “blah blah”?

You can eval a string as markup:

#let food-review = "now _that's_ a spicy meatball"
#eval(food-review, mode: "markup")

However, if the package is expecting a string as an input and then doing string operations on it, then there’s not much you can do; you’d have to change the function yourself to accept content.

1 Like

Hey @stelmo, welcome to the forum! I’ve changed your question post’s title to better fit our guidelines: How to post in the Questions category

For future posts, make sure your title is a question you’d ask to a friend about Typst. :wink:

1 Like