Inline code
Wrap a short snippet in single backticks to set it in monospace: writing `npm install` renders as npm install. Handy for filenames, commands, and anything that should not be autocorrected.
Code blocks
For longer code, use a fenced block: three backticks on their own line, your code, then three backticks to close. Add a language after the opening fence to get syntax highlighting:
```js
function greet(name) {
return `Hello, ${name}`
}
```
The block renders with a subtle background and the language shown as a label. Highlighting covers popular languages and adapts to your theme, in both light and dark mode.
Tips
- Typing three backticks at the start of a line converts it into a code block immediately.
- Inside a block, Enter adds a new line and Tab inserts a real tab. Nothing is auto-formatted, autocorrected, or treated as markdown.
- On the iPhone, iPad, and Mac apps, press Enter twice at the end of a block to hop out and continue writing below it.