TypstDocumentation

rawShowable
Question mark

Raw text with optional syntax highlighting.

Displays the text verbatim and in a monospace font. This is typically used to embed computer code into your document.

Syntax

This function also has dedicated syntax. You can enclose text in 1 or 3+ backticks (`) to make it raw. Two backticks produce empty raw text. When you use three or more backticks, you can additionally specify a language tag for syntax highlighting directly after the opening backticks. Within raw blocks, everything is rendered as is, in particular, there are no escape sequences.

Example

Adding `rbx` to `rcx` gives
the desired result.

```rust
fn main() {
    println!("Hello World!");
}
```
Preview

Parameters
Question mark

text
stringRequiredPositional
Question mark

The raw text.

You can also use raw blocks creatively to create custom syntaxes for your automations.

// Parse numbers in raw blocks with the
// `mydsl` tag and sum them up.
#show raw.where(lang: "mydsl"): it => {
  let sum = 0
  for part in it.text.split("+") {
    sum += int(part.trim())
  }
  sum
}

```mydsl
1 + 2 + 3 + 4 + 5
```
Preview

block

Whether the raw text is displayed as a separate block.

// Display inline code in a small box
// that retains the correct baseline.
#show raw.where(block: false): rect.with(
  fill: luma(240),
  inset: (x: 3pt, y: 0pt),
  outset: (y: 3pt),
  radius: 2pt,
)

// Display block code in a larger box
// with more padding.
#show raw.where(block: true): rect.with(
  fill: luma(240),
  inset: 10pt,
  radius: 4pt,
)

With `rg`, you can search through your files quickly.

```bash
rg "Hello World"
```
Preview

lang
nonestringSettable
Question mark

The language to syntax-highlight in.

Apart from typical language tags known from Markdown, this supports the "typ" and "typc" tags for Typst markup and Typst code, respectively.

```typ
This is *Typst!*
```
Preview