highlight

package
v0.0.0-...-8034f4b Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package highlight maps Go source code to syntax-highlighted byte ranges.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind int

Kind identifies the syntax class of a highlighted range.

const (
	// KindKeyword is a Go keyword.
	KindKeyword Kind = iota

	// KindString is a string or character literal.
	KindString

	// KindNumber is an integer, floating-point, or imaginary literal.
	KindNumber

	// KindComment is a line or general comment.
	KindComment

	// KindDeclName is the identifier immediately following the func or type
	// keyword.
	KindDeclName
)

type Range

type Range struct {
	// StartInBytes is the inclusive start byte offset of the range.
	StartInBytes int

	// EndInBytes is the exclusive end byte offset of the range.
	EndInBytes int

	// Kind is the syntax class of the range.
	Kind Kind
}

Range is a byte range of source code with a syntax class.

func AppendRanges

func AppendRanges(ranges []Range, src string) []Range

AppendRanges appends the highlighted ranges of the Go source code src to ranges and returns the extended slice. The appended ranges are in ascending order of StartInBytes and do not overlap. Scan errors are ignored so that incomplete code still yields ranges.

Jump to

Keyboard shortcuts

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