diff

package
v0.0.0-...-5fc8081 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package diff provides content diffing functionality for change detection.

This package is responsible for: - Generating unified diffs (text format) - Generating HTML diffs (side-by-side and inline) - Detecting meaningful changes (ignoring whitespace)

This file does NOT handle: - Content fetching (fetch package handles this) - Storage of diffs (store package handles this) - Webhook delivery (webhook package handles this)

Invariants: - All functions handle empty strings gracefully - HTML output is properly escaped - Unified diff format follows standard unified diff conventions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateStyles

func GenerateStyles() string

GenerateStyles returns CSS styles for HTML diffs.

func HTMLDiff

func HTMLDiff(oldText, newText string) string

HTMLDiff generates an HTML side-by-side diff.

func HasMeaningfulChanges

func HasMeaningfulChanges(oldText, newText string) bool

HasMeaningfulChanges checks if content has meaningful changes (ignores whitespace-only changes).

func InlineDiff

func InlineDiff(oldText, newText string) string

InlineDiff generates an inline HTML diff with highlights.

func UnifiedDiff

func UnifiedDiff(oldText, newText, filename string) string

UnifiedDiff generates a unified text diff between old and new content.

Types

type Config

type Config struct {
	Format           Format
	ContextLines     int
	IgnoreWhitespace bool
}

Config holds configuration for diff generation.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a default configuration.

type Format

type Format string

Format represents the output format for diffs.

const (
	FormatUnified        Format = "unified"
	FormatHTMLSideBySide Format = "html-side-by-side"
	FormatHTMLInline     Format = "html-inline"
)

type Result

type Result struct {
	HasChanges     bool
	UnifiedDiff    string
	HTMLDiff       string
	OldSize        int
	NewSize        int
	ChangesAdded   int
	ChangesRemoved int
}

Result contains the diff output and metadata.

func Generate

func Generate(oldText, newText string, cfg Config) Result

Generate creates a diff between old and new content.

Jump to

Keyboard shortcuts

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