TextMate
Colours code blocks with TextMate grammars, through TextMateSharp, which is where the languages come from too. F#, C#, JSON, YAML, HTML, CSS, JavaScript, TypeScript, shell, XML and markdown are all in it, and you configure nothing.
Add it
dotnet add package Nacara.Plugin.Highlight.TextMate --prerelease
Site.create "My library"
|> Markdown.register
|> TextMate.register
That is the whole setup. Any fenced block with a language now gets colour:
```fsharp
let greet name = printfn $"Hello, %s{name}"
```
let greet name = printfn $"Hello, %s{name}"
Colours
A grammar's scopes become the theme's token classes - tok-keyword, tok-string, and the rest of a small vocabulary. Recolour one there and it changes everywhere.
When a language is unknown
Your code is rendered as you wrote it, without colour, and the build tells you where:
! content/guide/deploy.md(48,1): warning markdown/unknown-language: No highlighter knows 'gleam', so this block is rendered without colour
hint: Check the spelling, register a highlighter that covers it, or label the fence 'text' when it is not code
It is a warning, never an error, and it comes from the markdown plugin, which knows the page and the line - a highlighter only ever sees a language. Turn it off there with WarnOnUnknownLanguage = false.
A fence labelled text, console, diff or the like is asking for no colour, so it is never reported. Neither is a fence with no language at all.
Reference
Every function and option of it, signature by signature: TextMate.