textdiff

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package textdiff compares two texts for a side-by-side view: by paragraphs, then by words inside the paragraphs that changed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Op

type Op int

Op - what happened to a Segment's text.

const (
	// Equal - in both texts.
	Equal Op = iota
	// Delete - only in the old text.
	Delete
	// Insert - only in the new text.
	Insert
)

type Paragraph

type Paragraph []Segment

Paragraph - one paragraph's segments.

func Compare

func Compare(before, after []string) (oldSide, newSide []Paragraph)

Compare - before and after (paragraphs each) side by side: the old side's paragraphs with Delete segments, the new side's with Insert ones. Equal paragraphs come as they are; a changed paragraph paired with the new one in its place is compared word by word.

type Segment

type Segment struct {
	Text string
	Op   Op
}

Segment - a run of text with one Op.

func (Segment) Changed

func (s Segment) Changed() bool

Changed - the segment is a deletion or an insertion.

Jump to

Keyboard shortcuts

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