yaml

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractContext

func ExtractContext(content string, loc domain.Location, before, after int) []string

ExtractContext extracts source lines around a location for error display. before and after specify how many lines to include before and after the target line. Returns empty slice if the location is invalid.

func ExtractContextBytes

func ExtractContextBytes(content []byte, loc domain.Location, before, after int) []string

ExtractContextBytes is like ExtractContext but takes []byte input.

func HighlightColumn

func HighlightColumn(content string, loc domain.Location) string

HighlightColumn creates a visual pointer at the specified column. Returns a string with the source line and a pointer line below it.

func HighlightColumnWithLength

func HighlightColumnWithLength(content string, loc domain.Location, length int) string

HighlightColumnWithLength creates a visual pointer spanning multiple characters. Returns a string with the source line and a pointer line below it.

Types

type LocationTracker

type LocationTracker struct {
	// contains filtered or unexported fields
}

LocationTracker tracks the source locations (line/column) of YAML fields. This is essential for providing accurate error messages with file locations.

func NewLocationTracker

func NewLocationTracker(content []byte) (*LocationTracker, error)

NewLocationTracker creates a LocationTracker from YAML content.

func NewLocationTrackerWithFile

func NewLocationTrackerWithFile(content []byte, filePath string) (*LocationTracker, error)

NewLocationTrackerWithFile creates a LocationTracker with an associated file path.

func (*LocationTracker) GetLocation

func (t *LocationTracker) GetLocation(path string) domain.Location

GetLocation returns the location of a field specified by path. Path uses dot notation for nested fields (e.g., "metadata.author") and bracket notation for array indices (e.g., "tags[0]" or "[0].id"). Returns a zero location if the path is not found.

func (*LocationTracker) GetValueLocation

func (t *LocationTracker) GetValueLocation(path string) domain.Location

GetValueLocation returns the location of a field's value. This finds the value node, not the key node.

Jump to

Keyboard shortcuts

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