paddiff

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package paddiff is a port of the original Etherpad src/node/utils/padDiff.ts.

It composes the changesets between two revisions of a pad into a single "diff" atext: all insertions of the range keep their author attribution and all deletions are re-inserted at the position they were deleted from, carrying a 'removed' attribute plus the author who deleted them. The resulting atext can be rendered with the regular export-HTML pipeline (lib/io/exportHtml.go understands the 'removed' attribute) to visualize the changes between the two revisions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDiffAText

func CreateDiffAText(p Pad, pool *apool.APool, fromRev int, toRev int) (*apool.AText, []string, error)

CreateDiffAText builds the diff atext between fromRev and toRev (both inclusive endpoints of the revision range, fromRev <= toRev <= head) and returns it together with the list of authors that contributed changes in that range. Like the original PadDiff, it adds the needed 'author' and 'removed' attributes to the supplied pool (in memory only; the pad record itself is not saved).

func GetValidRevisionRange

func GetValidRevisionRange(startRev int, endRev *int, head int) (from int, to int, ok bool)

GetValidRevisionRange mirrors Pad.getValidRevisionRange of the original Etherpad: startRev must lie within [0, head]; endRev defaults to head when nil, is clamped to head and must not be lower than startRev. ok is false when the range is invalid.

Types

type Pad

type Pad interface {
	GetInternalRevisionAText(targetRev int) *apool.AText
	GetRevision(revNumber int) (*db2.PadSingleRevision, error)
}

Pad is the subset of *padModel.Pad that is needed to build a diff. It is an interface so the diff logic can be unit tested with an in-memory fake.

Jump to

Keyboard shortcuts

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