Hi there. Newbie question here.
The str type has many facilities such as regex manipulation not available for content material.
Let’s assume there’s a need to process a certain text as a string as we do with a template and to compose the resulting text from the union of the model with data. With this objective in mind, I haven’t been able to compose a string as markup text. For example, in the following code, I would expect the string to be typesetted as content, but it’s not the case.
#let s = "This is a *string* defining $pi$ as $3.14$!"
#s
This function should only be used as a last resort.
I’m not an expert of the Typst compiler internals but I would think that converting text to content should be nearly cost-less while converting content to text is more costly. Someone with more expertise should probably answer this part.
May I suggest you move your question to the Questions category?
I read the “should only be used as a last resort” as “use the markup syntax [ .. ] unless you have a good reason not to”. I too have seen it used throughout various code examples here, on GitHub and on the Typst Discord.