syntax

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 10 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(line SpanLine, base lipgloss.Style) string

Render applies syntax attributes without losing the diff row's base style.

func Sanitize

func Sanitize(s string) string

Sanitize makes repository text safe to draw without changing printable text.

func Width

func Width(line SpanLine) int

Width returns the display-cell width of highlighted text.

Types

type SourceLine

type SourceLine struct {
	Number int
	Text   string
}

SourceLine identifies a line in one version of a file. Number is one-based.

type Span

type Span struct {
	Text       string
	Foreground color.Color
	Bold       bool
	Italic     bool
	Underline  bool
}

Span is terminal-safe source text with optional syntax attributes.

type SpanLine

type SpanLine []Span

SpanLine is one highlighted source line, split at syntax token boundaries.

func HighlightDiff

func HighlightDiff(path string, oldLines, newLines []SourceLine) (old, new []SpanLine)

HighlightDiff highlights the old and new versions independently, keeping syntax context across hunks of the same version.

func Truncate

func Truncate(line SpanLine, width int) SpanLine

Truncate limits highlighted text to width cells and adds an ellipsis when content does not fit.

func Wrap

func Wrap(line SpanLine, width int) []SpanLine

Wrap splits highlighted text at display-cell boundaries without carrying terminal styles across physical lines.

Jump to

Keyboard shortcuts

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