Code is highlighted, in the document's own colours
A fenced block with a language on it — ts, python, ```bash and about forty more — is now coloured, in the preview, the downloaded file, a shared link and every article on this site. Six colours rather than twenty, drawn from the same palette as the rest of the document, and they follow the theme you are reading in.
Put a language after the backticks and the block is coloured.
Six colours, not twenty
An editor theme paints twenty kinds of token because somebody is going to spend the afternoon in that file. A reader is skimming a snippet in the middle of a document, and a block painted in twenty colours reads as decoration rather than as code. So there are six roles — comments, keywords, strings, numbers, names and everything else — and they are the document's own colours, which is why the block does not look like a screenshot from somebody else's editor.
Switch between the light and dark theme and the colours move with it, in the preview and in the
file you download, because they are the same --md-* values the rest of the document is painted
with.
Which languages
About forty spellings resolve: the ones documentation is written in — shell, JavaScript and
TypeScript, Python, JSON, YAML, HTML, CSS, SQL, Go, Rust, Java, Kotlin, Swift, C and its family,
PHP, Ruby, Dockerfiles, TOML, GraphQL, diffs — and the short forms people actually type, so
sh, yml and ```tsx all land where you would expect.
A language nobody registered, or a fence with no language at all, is the plain code block it has always been. Nothing guesses: a highlighter asked to identify a three-line config file will cheerfully decide it is Perl, and a wrong colour is worse than none.
In the file, not in a stylesheet you have to keep
The colours ship inside the exported document like every other style it carries, so a saved file opens coloured on a machine with no network.