Code Blocks
Basic Code Block
Section titled “Basic Code Block”Wrap code in triple backticks with an optional language identifier:
```pythondef hello(): print("Hello, world!")```def hello(): print("Hello, world!")Supported Languages
Section titled “Supported Languages”Common languages are highlighted automatically. Some popular examples:
| Language | Identifier |
|---|---|
| Python | python |
| JavaScript | javascript or js |
| TypeScript | typescript or ts |
| Go | go |
| Rust | rust |
| HTML | html |
| CSS | css |
| YAML | yaml |
| JSON | json |
| Bash / Shell | bash or sh |
| Markdown | markdown or md |
| LaTeX | latex |
For non-standard languages, you may need to enable them in your configuration.
Line Highlighting
Section titled “Line Highlighting”Highlight specific lines to draw attention:
```python {2}def hello(): print("Hello, world!") # This line is highlighted! return True```def hello(): print("Hello, world!") # This line is highlighted! return TrueHighlight Ranges
Section titled “Highlight Ranges”```js {1, 3-5}This highlights line 1 and lines 3 through 5.
Inline Code
Section titled “Inline Code”Use single backticks for inline code:
Run `npm install` to install dependencies.Run npm install to install dependencies.
Inline Code with Backticks
Section titled “Inline Code with Backticks”If your code contains backticks, use double backticks:
Use `` `code` `` for inline code.Code Block Titles
Section titled “Code Block Titles”Add a title to your code block to show the filename:
```python title="hello.py"def hello(): print("Hello!")```def hello(): print("Hello!")Diff Syntax
Section titled “Diff Syntax”Show additions and removals with the diff language:
```diff- const old = "before";+ const new = "after"; const unchanged = "same";```const old = "before";const new = "after";const unchanged = "same";