Code Blocks
Syntax highlighting and multi-language examples
Fenced code blocks get automatic syntax highlighting.
Basic
const acme = new Acme('sk_live_abc123');
const payment = await acme.payments.create({
amount: 2500,
currency: 'usd',
});
Add a language after the opening fence:
```javascript
const acme = new Acme('sk_live_abc123');
```
With filename
server.js
import express from 'express';
import { Acme } from 'acme-sdk';
const app = express();
const acme = new Acme(process.env.ACME_API_KEY);
app.post('/charge', async (req, res) => {
const payment = await acme.payments.create({
amount: req.body.amount,
currency: 'usd',
});
res.json(payment);
});
app.listen(3000);```javascript server.js
import express from 'express';
// ...
```
Code groups
Show the same thing in multiple languages:
payment = acme.payments.create(
amount=2500,
currency='usd',
)<CodeGroup>
```javascript Node.js
const payment = await acme.payments.create({ ... });
```
```python Python
payment = acme.payments.create(...)
```
</CodeGroup>