Code Blocks
Fenced code blocks with automatic syntax highlighting, optional file titles, and CodeGroup for multi-language examples side by side.
Fenced code blocks are automatically syntax-highlighted. Use them for code examples, configuration snippets, and terminal commands.
Basic code block
Add a language identifier after the opening fence for syntax highlighting:
function greet(name) {
return `Hello, ${name}!`;
}
```javascript
function greet(name) {
return `Hello, ${name}!`;
}
```
With title
Add a title after the language identifier to label the file:
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Hello World');
});
app.listen(3000);```javascript server.js
const express = require('express');
const app = express();
app.listen(3000);
```
Code groups
Use CodeGroup to show the same example in multiple languages as switchable tabs:
import requests
response = requests.get('https://api.example.com/data')
data = response.json()
print(data)<CodeGroup>
```javascript Node.js
const response = await fetch('https://api.example.com/data');
const data = await response.json();
```
```python Python
import requests
response = requests.get('https://api.example.com/data')
data = response.json()
```
```bash cURL
curl -X GET https://api.example.com/data
```
</CodeGroup>
The title after the language identifier becomes the tab label.
Supported languages
All common languages are supported for syntax highlighting, including:
javascript/typescriptpythonbash/shelljson/yaml/tomlgo/rust/solidityhtml/css/sqlmdx/markdown
Inline code
Use single backticks for inline code references:
Use the `matrix://tool/mcp/<alias>/<tool>` URI scheme.
This renders as: Use the matrix://tool/mcp/<alias>/<tool> URI scheme.
Use code blocks for multi-line examples and inline code for single values, function names, or file paths within a paragraph.
