1= Code2
3Typst renders code blocks with syntax highlighting.4
5== Inline code6
7Use backticks for inline code: `let x = 42` or `SELECT * FROM users`.8
9== Code blocks10
11A raw block with language hint for syntax highlighting:12
13```rust14fn fibonacci(n: u64) -> u64 {15 match n {16 0 => 0,17 1 => 1,18 _ => fibonacci(n - 1) + fibonacci(n - 2),19 }20}21```22
23```python24def quicksort(arr):25 if len(arr) <= 1:26 return arr27 pivot = arr[len(arr) // 2]28 left = [x for x in arr if x < pivot]29 middle = [x for x in arr if x == pivot]30 right = [x for x in arr if x > pivot]31 return quicksort(left) + middle + quicksort(right)32```33
34```typescript35async function fetchData<T>(url: string): Promise<T> {36 const response = await fetch(url);37 if (!response.ok) {38 throw new Error(`HTTP ${response.status}`);39 }40 return response.json();41}42```43
44```sql45SELECT users.name, COUNT(orders.id) AS order_count46FROM users47LEFT JOIN orders ON users.id = orders.user_id48WHERE users.created_at > '2024-01-01'49GROUP BY users.name50HAVING COUNT(orders.id) > 551ORDER BY order_count DESC;52```53
54== Plain code blocks55
56Without a language hint, code renders without highlighting:57
58```59this is a plain code block60no syntax highlighting applied61just monospace text62``` v1
commit 9152b37
message create code.typ via macOS
author anton
date Apr 18, 2026
size 1.2 KB