Code Blocks
Code Blocks
Code is a first-class citizen in Tachyonn. You write code blocks exactly as you would in Markdown — three backticks, the language name, your code, and three backticks to close:
```python
def greet(name):
print(f"Hello, {name}!")
```Naming the language (here, python) turns on syntax highlighting, powered by Shiki. It runs entirely on your machine, with the color theme bundled in — no internet needed, in keeping with Tachyonn's offline-first design.
Supported languages
All the major languages are recognized: python, rust, javascript, typescript, go, c, cpp, java, ruby, bash, json, html, css, and many more. Use the language's usual short name after the opening backticks.
Code block options
Options go in {…} right after the language name:
| Option | Effect |
|---|---|
highlight=N | Emphasize line(s): 2, 2,4, or a range 2-5 |
highlight=a|b|c | Incremental — each | group lights up on the next click (the last stays); adds clicks to the slide |
lineNumbers / ln | Show the line-number gutter; lineNumbers=10 starts counting at 10 |
title="…" | A title bar above the code |
wrap | Wrap long lines inside the box instead of scrolling sideways |
io | Attach input/output sub-boxes (below) |
reveal | With io: reveal code, then input, then output — one click each |
```python {highlight=2 lineNumbers title="argv.py"}
import sys
print(sys.argv) # this line is highlighted
```Input & output boxes
Add io and, inside the fence, mark regions with --- input and --- output.
Each becomes a named sub-box rendered below the code (only the code region is
highlighted). Text after the marker renames the box (e.g. --- input stdin). Addreveal to walk code → input → output one click at a time:
```python {io, reveal}
n = int(input())
print(n * n)
--- input
5
--- output
25
```Inline code
For a short snippet inside a sentence, wrap it in single backticks:
Call the `compile_file()` function to parse a deck.That renders as compile_file() in a monospace font, without starting a new block.
A dedicated code layout
When a code sample is the star of the slide, give it the code-window layout. It frames your code in a styled window and gives it room to breathe:
## The parser entry point
===
layout: code-window
===
```rust
fn parse(input: &str) -> AST {
let tokens = lexer(input);
parser().parse(tokens)
}
```Choosing the code font
The monospace font is set by the fontMono property in your frontmatter (or your theme). Set it to a coding font you like — JetBrains Mono, Fira Code, and Source Code Pro all look great on slides.