highlight

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 5 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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