diff

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Type     DiffType
	Old      string
	New      string
	Position int // Paragraph or line number
	Context  string
}

Change represents a single change in the diff

type DiffOptions

type DiffOptions struct {
	// IgnoreWhitespace ignores whitespace differences
	IgnoreWhitespace bool

	// IgnoreCase ignores case differences
	IgnoreCase bool

	// ContextLines number of context lines to show around changes
	ContextLines int

	// MinChangeLength minimum length to consider a change
	MinChangeLength int
}

DiffOptions holds options for diff operations

func DefaultDiffOptions

func DefaultDiffOptions() DiffOptions

DefaultDiffOptions returns default diff options

type DiffResult

type DiffResult struct {
	Changes     []Change
	Stats       DiffStats
	OldDocument string
	NewDocument string
}

DiffResult represents the result of comparing two documents

func CompareDOCX

func CompareDOCX(oldPath, newPath string, opts DiffOptions) (*DiffResult, error)

CompareDOCX is a convenience function to compare two DOCX files

type DiffStats

type DiffStats struct {
	TotalChanges   int
	AddedLines     int
	DeletedLines   int
	ModifiedLines  int
	UnchangedLines int
}

DiffStats holds statistics about the diff

type DiffType

type DiffType int

DiffType represents the type of change

const (
	DiffNone DiffType = iota
	DiffAdded
	DiffDeleted
	DiffModified
)

func (DiffType) String

func (d DiffType) String() string

type Differ

type Differ interface {
	Compare(old, new string) (*DiffResult, error)
}

Differ is the interface for diff implementations

type DocxDiffer

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

DocxDiffer compares DOCX documents

func NewDocxDiffer

func NewDocxDiffer(opts DiffOptions) *DocxDiffer

NewDocxDiffer creates a new DOCX differ

func (*DocxDiffer) Compare

func (d *DocxDiffer) Compare(oldPath, newPath string) (*DiffResult, error)

Compare compares two DOCX documents

type HTMLRenderer

type HTMLRenderer struct {
	ShowStats bool
}

HTMLRenderer renders diff as HTML

func NewHTMLRenderer

func NewHTMLRenderer(showStats bool) *HTMLRenderer

NewHTMLRenderer creates a new HTML renderer

func (*HTMLRenderer) Render

func (r *HTMLRenderer) Render(result *DiffResult) (string, error)

Render renders the diff result as HTML

type MarkdownRenderer

type MarkdownRenderer struct {
	ShowStats bool
}

MarkdownRenderer renders diff as Markdown

func NewMarkdownRenderer

func NewMarkdownRenderer(showStats bool) *MarkdownRenderer

NewMarkdownRenderer creates a new Markdown renderer

func (*MarkdownRenderer) Render

func (r *MarkdownRenderer) Render(result *DiffResult) (string, error)

Render renders the diff result as Markdown

type PlainTextRenderer

type PlainTextRenderer struct {
	ShowStats   bool
	ColorOutput bool
}

PlainTextRenderer renders diff as plain text

func NewPlainTextRenderer

func NewPlainTextRenderer(showStats, colorOutput bool) *PlainTextRenderer

NewPlainTextRenderer creates a new plain text renderer

func (*PlainTextRenderer) Render

func (r *PlainTextRenderer) Render(result *DiffResult) (string, error)

Render renders the diff result as plain text

type Renderer

type Renderer interface {
	Render(result *DiffResult) (string, error)
}

Renderer is the interface for diff renderers

Jump to

Keyboard shortcuts

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