highlight

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package highlight provides chroma-based syntax highlighting for fenced code blocks in goldmark-rendered Markdown.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Theme is a chroma style name (e.g. "github", "monokai", "dracula").
	// Defaults to "github".
	Theme string
	// LineNumbers enables line number display.
	LineNumbers bool
}

Config holds syntax highlighting settings derived from config.yaml.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default highlighting configuration.

type Highlighter

type Highlighter struct {
	// contains filtered or unexported fields
}

Highlighter renders fenced code blocks with chroma.

func New

func New(cfg Config) *Highlighter

New creates a Highlighter with the provided config.

func (*Highlighter) Extension

func (h *Highlighter) Extension() goldmark.Extender

Extension returns a goldmark.Extender that replaces the default fenced-code- block renderer with chroma-based highlighting.

func (*Highlighter) Highlight

func (h *Highlighter) Highlight(code, lang string) (string, error)

Highlight returns a syntax-highlighted HTML fragment for the given code and language. If the language is unknown or empty, it falls back to a plain <pre><code> block.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL