Markdown
Code blocks
Documents are where the fix you worked out at eleven at night lives, so code is treated properly:
Documents are where the fix you worked out at eleven at night lives, so code is treated properly:
- Coloured by its language — on screen and in the PDF.
- A name — write the language and then
title="whatever", and the name shows in the block’s header. - Line numbers beside the text, not in it — copying a block takes the code and nothing else.
Type / and pick Code block, or write the fence by hand.
fn time_to_take_her_out(hour: u8, been_out: bool) -> bool {
match (hour, been_out) {
(7..=9, false) => true,
(20..=22, false) => true,
_ => false,
}
}
```bash title="backup.sh"
rsync -a --delete ~/Tisty/ /Volumes/Backup/Tisty/
```
The name is what Markdown already keeps after the language, so other readers simply ignore it.
Some uses
A query you wrote once and that worked:
SELECT month, SUM(amount) AS total
FROM spending
WHERE category = 'vet'
GROUP BY month
ORDER BY total DESC;
What changed between the version that worked and the one that did not:
- const WALKS: u8 = 1;
+ const WALKS: u8 = 2;
Inline code
Inside a sentence, code goes between backticks: cargo build --release, Ctrl + C. It is not coloured because it does not need to be.
Tip Write why it was like that under the block. The block tells you what you did; the line after it tells you why — and that is the part you forget.
Special languages
Three languages are not shown as code but drawn: mermaid, math and widget.