Comments (4)
Its actually easy:
package main
import (
"fmt"
"github.com/sergi/go-diff/diffmatchpatch"
)
func diffRebuildtexts(diffs []diffmatchpatch.Diff) []string {
text := []string{"", ""}
for _, myDiff := range diffs {
if myDiff.Type != diffmatchpatch.DiffInsert {
text[0] += myDiff.Text
}
if myDiff.Type != diffmatchpatch.DiffDelete {
text[1] += myDiff.Text
}
}
return text
}
func main() {
dmp := diffmatchpatch.New()
a := "tiger"
b := "tigor"
diffs := dmp.DiffMain(a, b, true)
// Store as strings
delta := dmp.DiffToDelta(diffs)
fmt.Println(diffs)
text1 := dmp.DiffText1(diffs)
fmt.Println(text1, delta)
// rebuild from strings
seq1, _ := dmp.DiffFromDelta(text1, delta)
fmt.Println(seq1)
texts_linemode := diffRebuildtexts(seq1)
latest := texts_linemode[len(texts_linemode)-1]
fmt.Println(latest)
// add something else
newest := "tigre"
diffs = dmp.DiffMain(latest, newest, true)
// Store as strings
delta = dmp.DiffToDelta(diffs)
fmt.Println(diffs)
text1 = dmp.DiffText1(diffs)
fmt.Println(text1, delta)
// rebuild from strings
seq1, _ = dmp.DiffFromDelta(text1, delta)
fmt.Println(seq1)
texts_linemode = diffRebuildtexts(seq1)
latest = texts_linemode[len(texts_linemode)-1]
fmt.Println(latest)
}
from cowyo.
Its halfway there...got the diffs in there. Just need to make a client side way of accessing them.
from cowyo.
A subset of the diff documents should be shown to the user. Maybe all the documents that have a time between diffs of > 10 minutes? Or maybe a dynamic time setting that will allow fine/coarse adjustments. Or maybe just return the top 10 links to documents that have the greatest diffs between them.
from cowyo.
Done
from cowyo.
Related Issues (20)
- Locking and then Encrypting causes deadlock
- Sitemap.xml not regenerated HOT 1
- /ls page displays an "empty" entry due to sitemap.xml HOT 2
- Build failing on FreeBSD 11.2 HOT 4
- Self-destructing pages don't work well with /raw
- 966591517640 HOT 2
- Support for directories/hierarchy
- Instead of using data folder, files are uploaded to /root/pathToData HOT 1
- Nested bullet points do not render correctly HOT 1
- Asciidoc support
- build failed HOT 1
- May there have a nginx example for proxy this service? HOT 1
- Locking and encryption together = lost data.
- Support for living editing?
- Dark mode? HOT 1
- 1
- Cannot restore an image through history HOT 1
- Automatically upload images when paste HOT 2
- view vs read .. it's confusing and has the wrong default
- Installation at non-root url path
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cowyo.