1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-28 17:49:41 +02:00
documize/vendor/github.com/documize/html-diff
Harvey Kandola fd693f4ff4 go dep
Migrated from plain /vendor to go dep
2018-02-14 15:23:46 +00:00
..
.gitignore rollback page revisions 2016-11-30 17:56:36 -08:00
append.go rollback page revisions 2016-11-30 17:56:36 -08:00
clean.go rollback page revisions 2016-11-30 17:56:36 -08:00
example_test.html rollback page revisions 2016-11-30 17:56:36 -08:00
example_test.png rollback page revisions 2016-11-30 17:56:36 -08:00
fuzz.go rollback page revisions 2016-11-30 17:56:36 -08:00
htmldiff.go rollback page revisions 2016-11-30 17:56:36 -08:00
LICENSE rollback page revisions 2016-11-30 17:56:36 -08:00
nodes.go rollback page revisions 2016-11-30 17:56:36 -08:00
pos.go rollback page revisions 2016-11-30 17:56:36 -08:00
README.md rollback page revisions 2016-11-30 17:56:36 -08:00
treerunes.go rollback page revisions 2016-11-30 17:56:36 -08:00

html-diff

Calculate difference between two HTML snippets and return those differences as a merged HTML snippet showing the changes.

Usage:

	var cfg = &htmldiff.Config{
		Granularity:  5,
		InsertedSpan: []htmldiff.Attribute{{Key: "style", Val: "background-color: palegreen;"}},
		DeletedSpan:  []htmldiff.Attribute{{Key: "style", Val: "background-color: lightpink;"}},
		ReplacedSpan: []htmldiff.Attribute{{Key: "style", Val: "background-color: lightskyblue;"}},
		CleanTags:    []string{""},
	}
	res, err := cfg.HTMLdiff([]string{previousHTML, latestHTML})
	mergedHTML := res[0]

see example_test.go

Only deals with body HTML, so no headers, only what is within the body element.

Requires Go1.5+, with vendoring support. Vendors "github.com/mb0/diff", "golang.org/x/net/html" and "golang.org/x/net/html/atom".

Running the tests will create output files in testout/*.html.

For fuzz-testing using https://github.com/dvyukov/go-fuzz , the Fuzz() function is in fuzz.go (as at Feb'16 you need to rename the vendor directory while you fuzz, and go get the dependencies - an issue with "go/importer", see https://github.com/golang/go/issues/13756).

Pull requests welcome.