Code blocks and syntax highlighting

By:
3 min read
Premium
Neutrino highlights code automatically — for three languages. Everything else renders as clean, readable, unhighlighted code, and that is by design rather than by oversight.

Code blocks in Neutrino are styled for reading: a monospaced face, a background that separates the block from the prose around it, comfortable padding, and colours that work in both light and dark mode without you doing anything.

Syntax highlighting covers three languages — HTML and XML, CSS, and JavaScript. Those are the languages a Ghost site's readers most often need, and shipping only them keeps the page weight down for the very large number of sites that publish no code at all. Everything else — Python, Ruby, Go, Rust, SQL, shell — renders as plain, correctly formatted, monospaced code. It is entirely readable; it just is not coloured.

Long lines scroll horizontally inside their own block rather than wrapping or pushing the page sideways, which matters more than it sounds: wrapped code is misleading, because an unintended line break in a shell command or a string literal changes what the reader thinks they are looking at.

This post is only for members

Get access to premium content by becoming a member.

See pricing plans