highlight

package
v0.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package highlight provides a simple, allocation-light syntax tokenizer for use in DOCX code-block rendering. It is intentionally small — no external dependencies, no regex, no full parser — just enough to give code blocks meaningful colour in a Word document.

Index

Constants

View Source
const (
	ColorKeyword = "000080" // navy
	ColorString  = "A31515" // dark red
	ColorComment = "008000" // dark green
	ColorNumber  = "098658" // teal
	ColorType    = "267F99" // blue-green
	ColorBuiltin = "795E26" // brown / function gold
)

Colour palette (print-friendly, similar to VS Code Light+)

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token struct {
	Text  string // raw source text (may contain \n for block tokenisation)
	Color string // 6-digit hex RGB, empty = document default (black)
}

Token is a contiguous span of source text with an optional colour.

func Tokenize

func Tokenize(code, lang string) []Token

Tokenize splits code into coloured tokens for the given language identifier (e.g. "go", "python", "javascript"). Unrecognised or empty lang returns a single unstyled token so the text is still emitted correctly.

Jump to

Keyboard shortcuts

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