Syntax Highlighting

Kiln includes robust support for code syntax highlighting out of the box. It automatically detects code blocks in your Markdown and applies coloring based on the specified language.

Usage

To use it, simply wrap your code in triple backticks and specify the language identifier.

```go
package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}
```

Result:

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

How It Works

Kiln uses a Class-Based highlighting system (powered by Chroma).

Unlike some generators that force specific colors using inline styles, Kiln generates clean HTML with semantic classes.

Example Output:

<span class="keyword">func</span> 
<span class="function">main</span>()

This approach has two major benefits:

  1. Performance: The CSS is loaded once, keeping your HTML file size small.
  2. Theming: The style.css that was generated by the theme is also applied to your code snippets.

Customization

Because the styling is handled by CSS, your code blocks automatically adapt to Light and Dark modes. You can customize the specific colors for keywords, strings, or comments by targeting the .chroma classes in your stylesheet.