Why does a semicolon go missing from output when inserted directly after code expression?

I just had a problem where I have the following code:

#set page(height: auto, width: auto, margin: 1cm)

The semicolon after this #{[code epxression]}; will disappear.

Is the disappearance of the semicolon after #{} intended behavior? How would you correct it? Indeed it happens after any code expression, namely functions etc. Adding a space between the code expression and the semicolon also adds an actual space in the output, so how would you fix this?

1 Like

I just found out that one can escape the semicolon with a backslash.

#set page(height: auto, width: auto, margin: 1cm)

After this #{[code expression]}\; the semicolon will appear.

Still the question remains if this is intended behavior.

from the docs

If a character would continue the expression but should be interpreted as text, the expression can forcibly be ended with a semicolon (; ).

Scripting – Typst Documentation.

So writing #{ ...};, the semicolon directly after } is interpreted as the expression termination character.

2 Likes

Ah ok I see. I guess that makes sense. So I could also write

After this #{[code expression]};; the semicolon will appear.

Hi @SebastianJL, I have moved your question to the Questions category, please make sure to check the category when creating a topic :slight_smile: that also means that you can select an answer. If you feel the response you got has sufficiently answered your question, be sure to give it a checkmark. This will help others find the solution in the future. Thanks!

Thanks for the gentle slap on the wrist :slight_smile: I went back and marked questions as solved in past threads. Unfortunately I wasn’t able to change the categories for all posts that where questions. Sorry for posting a bit carelessly. The forum has been a great help this week.

1 Like