diff

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeUnifiedDiff

func ComputeUnifiedDiff(oldStr, newStr string, contextLines int) string

ComputeUnifiedDiff generates a unified diff format string

func FormatDiffHTML

func FormatDiffHTML(lines []DiffLine) template.HTML

FormatDiffHTML formats diff lines as HTML

func FormatDiffInline

func FormatDiffInline(line DiffLine) string

FormatDiffInline formats a single diff line

Types

type DiffLine

type DiffLine struct {
	Type    LineType
	Content string
	LineNum int
}

DiffLine represents a line in the diff with its type and content

func ComputeLineDiff

func ComputeLineDiff(oldStr, newStr string) []DiffLine

ComputeLineDiff computes a simple line-based diff between two strings

type LineType

type LineType int

LineType represents the type of change in a diff line

const (
	// LineUnchanged represents an unchanged line
	LineUnchanged LineType = iota
	// LineAdded represents an added line
	LineAdded
	// LineRemoved represents a removed line
	LineRemoved
)

func (LineType) CSSClass

func (lt LineType) CSSClass() string

CSSClass returns the CSS class name for the line type

func (LineType) Prefix

func (lt LineType) Prefix() string

Prefix returns the diff prefix character for the line type

func (LineType) String

func (lt LineType) String() string

String returns the string representation of the line type

Jump to

Keyboard shortcuts

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