Documentation
¶
Index ¶
- func ColoredText(d *DiffSolution) string
- func DiffToHTML(a, b string) (string, error)
- func DiffToText(a, b string) string
- func HTML(d *DiffSolution) string
- func HTMLLine(d *DiffSolution) (string, string)
- func Text(d *DiffSolution) string
- type DiffSolution
- type HistogramDiffer
- type LineSource
- type Metadata
- type SequenceDiffer
- type Solver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColoredText ¶
func ColoredText(d *DiffSolution) string
func DiffToHTML ¶
func DiffToText ¶
func HTML ¶
func HTML(d *DiffSolution) string
HTML builds up a html diff. Here be dragons! This is meant for the delta GUI.
func HTMLLine ¶
func HTMLLine(d *DiffSolution) (string, string)
HTMLLine renders a diff solution into a before and after string. Words are added one at a time, and changes are marked with spans.
func Text ¶
func Text(d *DiffSolution) string
Types ¶
type DiffSolution ¶
type DiffSolution struct {
Lines [][3]string
}
DiffSolution contains a set of lines, where each element of lines comprises the left and right line, and whether the change was from A or B.
func HistogramDiff ¶
func HistogramDiff(a, b string) *DiffSolution
HistogramDiff uses the histogram diff algorithm to generate a line-based diff between two strings
func SequenceDiff ¶
func SequenceDiff(a, b string) *DiffSolution
SequenceDiff two strings using dynamic programming and return a DiffSolution.
func (*DiffSolution) PostProcess ¶
func (d *DiffSolution) PostProcess()
PostProcess loops over the solution. For each changed region, see if we can move it forward. i.e. if we have the following changeset:
a [b c d] b c
then we move the modified region forward so we have instead:
a b c [d b c]
this heuristic only moves additions or deletions (but never both in a move).
func (*DiffSolution) Text ¶
func (d *DiffSolution) Text() string
type HistogramDiffer ¶
type HistogramDiffer struct {
// contains filtered or unexported fields
}
HistogramDiffer implements the histogram diff algorithm.
func NewHistogramDiffer ¶
func NewHistogramDiffer(a, b []string) *HistogramDiffer
NewHistogramDiffer returns a HistogramDiffer which diffs the given sequence of words.
func (*HistogramDiffer) Solve ¶
func (h *HistogramDiffer) Solve() *DiffSolution
Solve returns a DiffSolution. Internally it uses solveRange to find all matching regions, then it uses the standard differ to create diffs on the intra-region area.
type LineSource ¶
type LineSource string
LineSource indicates the origin of the solution line.
const ( Unknown LineSource = "" LineFromA LineSource = "<" LineFromB LineSource = ">" LineFromBoth LineSource = "=" LineFromBothEdit LineSource = "~" )
These are valid values for LineSource.
type SequenceDiffer ¶
type SequenceDiffer struct {
// contains filtered or unexported fields
}
SequenceDiffer computes a diff using a dynamic programming algorithm.
func NewSequenceDiffer ¶
func NewSequenceDiffer(a, b []string) *SequenceDiffer
NewSequenceDiffer returns a new SequenceDiffer to compare two lists of strings.
func (*SequenceDiffer) Solve ¶
func (d *SequenceDiffer) Solve() *DiffSolution
Solve the diff using dyanmic programming.
type Solver ¶
type Solver interface {
Solve() *DiffSolution
}
Solver is an interface implemented by the diff algorithms.