Typst showed up in Homebrew the other day, and I’ve been playing around with it a little bit. I like it.

It took me a bit to figure out how to style code blocks, though. Raw text in Typst come in two types:

Changing style for all text is easy:

#set text(
    font: "Seravek", size: 18pt
)

Changing style for all headings is a bit more complicated:

#show heading: (it) => block[
    #set text(font: "Recent Grotesk")
    #block(it.body)
]

For raw text, though, you’ll want to handle the block and not-block styles separately:

#show raw.where(block: false): (it) => text[
    #set text(font: "Cascadia Code")
    #text(it.text)
]

#show raw.where(block: true): (it) => block[
    #set text(font: "Cascadia Code")
    #block(it.text)
]

If you neglect to put in the .where(…) clause and duplicate everything for the other style, like I did at first, you’ll end up forcing all your raw text to be either block or not-block, depending on whether you put text or block right after the arrow.

Finally, you could do something even simpler, and dispose of the redundant block/text bits and consolidate into one show rule with a function:

#show raw: (it) => [
    #set text(font: "Cascadia Code")
    #it
]