Using Expressive Code
Sidey uses Expressive Code for syntax highlighting. It works out of the box — just write a fenced code block in your markdown and it gets highlighted automatically.
Basic usage
Wrap your code in triple backticks and specify the language:
```tsconst greeting = "Hello, world!"console.log(greeting)```You can also add a title to the code block:
```ts title="src/utils/greeting.ts"const greeting = "Hello, world!"console.log(greeting)```Line numbers
Line numbers are disabled by default. Enable them per block with showLineNumbers:
```ts showLineNumbersconst a = 1const b = 2const c = a + b```Line highlighting
You can highlight specific lines to draw attention to them:
```ts {2-3}const a = 1const b = 2const c = a + b```Or highlight a single line:
```ts {2}const a = 1const b = 2const c = a + b```Collapsible sections
Long code blocks can be collapsed to keep the page readable.
Sidey uses collapsible-auto by default, which collapses sections automatically.
Mark a range of lines as collapsible with collapse:
```ts collapse={2-4}3 collapsed lines
// This line is visibleconst a = 1const b = 2const c = a + b// This line is visible too```Combining features
All features can be combined in a single block:
```ts title="src/utils/math.ts" showLineNumbers {3} collapse={5-8}// Math utilitiesconst add = (a: number, b: number) => a + bconst subtract = (a: number, b: number) => a - b4 collapsed lines
const multiply = (a: number, b: number) => a * bconst divide = (a: number, b: number) => { if (b === 0) throw new Error("Cannot divide by zero") return a / b}```This page covers what is available in Sidey out of the box. Expressive Code has a lot more to offer, visit the Expressive Code documentation for the full list of features and options.