highlight

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package highlight provides Chroma-based syntax highlighting for the editor It tokenizes document text and maps Chroma token types to terminal styles

Index

Constants

View Source
const (
	LogError     = "ERR"
	LogWarning   = "WAR"
	LogInfo      = "INF"
	LogCommand   = "CMD"
	LogTerminal  = "TRM"
	LogSeparator = " " + tui.BorderV + " "
)

LogError, LogWarning, LogInfo, LogCommand and LogTerminal are the tags the message log writes at the start of each line, naming the severity or the source, LogSeparator the rule drawn after them

Variables

This section is empty.

Functions

func DefaultStyle

func DefaultStyle(scope string) tui.Style

DefaultStyle returns the fallback ANSI style for a scope name when no theme is active or the theme does not define the scope

func NormalizeNewlines

func NormalizeNewlines(s string) string

NormalizeNewlines replaces \r\n with \n for consistent tokenization

Types

type Span

type Span struct {
	Start int // inclusive char offset
	End   int // exclusive char offset
	Scope string
}

Span represents a highlighted region in the document

func Tokenize

func Tokenize(src core.Source) []Span

Tokenize parses text using Chroma and returns highlight spans with theme scope names. Prefer calling syntax.Tokenize which tries Tree-sitter first and uses this as a fallback

Jump to

Keyboard shortcuts

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