highlight

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package highlight turns source text into ANSI-styled text using the Chroma lexers and styles, so that YAML, JSON, SQL and friends can be shown in a TextPane or any other widget that renders ANSI.

Index

Constants

View Source
const DefaultStyle = "dracula"

DefaultStyle is the Chroma style used by YAML and Language.

Variables

This section is empty.

Functions

func Colorize

func Colorize(text, styleName string, lexer chroma.Lexer) (string, error)

Colorize tokenises text with lexer and returns it with each token wrapped in the SGR sequences of the named Chroma style. A nil lexer selects Chroma's plain-text fallback. An unknown style falls back to Chroma's default style.

func Language

func Language(text, language string) (string, error)

Language highlights text as the named language (a Chroma lexer name or alias such as "yaml", "json" or "sql") using DefaultStyle. An unknown language returns the text as plain text.

func YAML

func YAML(text string) (string, error)

YAML highlights YAML text using DefaultStyle.

Types

This section is empty.

Jump to

Keyboard shortcuts

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