Is code in my book syntax highlighted?
Yes. Code blocks in technical books are syntax highlighted, meaning each part of the code is colored by what it does: keywords in red, text values in green, numbers in blue, and comments in gray. Everything else stays the color of the surrounding text.
The coloring carries across every format: reading online, PDF, EPUB, Kindle, and Word. In Word it arrives as real, editable text rather than a picture, so you can change the code and keep the colors. Plain-text Markdown downloads have no formatting layer, so code there is uncolored.
Which languages are covered
More than 35, including Python, JavaScript, TypeScript, Java, C, C++, C#, Go, Rust, Ruby, PHP, Swift, Kotlin, SQL, HTML, CSS, YAML, JSON, Bash, and PowerShell. Configuration and markup formats such as Dockerfile, nginx, TOML, LaTeX, and Markdown are covered too.
When code stays plain
Some code blocks appear in plain black, and that's deliberate. If the language can't be identified confidently, or the block isn't really code (ASCII diagrams, sample output, made-up pseudocode), it's left uncolored. Coloring a block as the wrong language is more confusing than leaving it alone, so anything uncertain stays plain.
Books written before this feature arrived are colored by automatic detection alone, so a less common language may stay plain in an older book even though it's colored in a new one.
Short code references inside a sentence, like a single function name, are shown in a monospaced font on a light background rather than colored.
Why the colors look different on a Kindle or in a reading app
E-readers let you choose your page color, and they adjust the code colors to suit it rather than showing them exactly as written. This applies to a Kindle and to reading apps like Apple Books, and each one adjusts a little differently.
On a Kindle, here's what to expect:
- White page. Colors appear close to how they were designed.
- Black (night) page. The code panel becomes a medium gray and the colors are brightened, so the block stays readable without glaring on a dark screen.
- Sepia or green page. The colors are tinted toward the page color, so red and blue read as warmer, softer versions of themselves.
In an app with a dark mode, such as Apple Books, the code panel switches to a dark background and the colors stay as they are, which is why they can look more vivid there than on a Kindle's night page.
This is your reader doing its job, not a fault in the file. Every theme keeps the different parts of the code distinguishable, which is the point of coloring them.
If you want to see the colors exactly as designed, open the PDF instead. PDFs keep a fixed appearance everywhere, so nothing gets repainted.