highlight

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 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 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