How can one generate the new text given the old text and a diff? #91
Unanswered
ceilidhboy
asked this question in
Q&A
Replies: 1 comment
-
|
Unfortunately, this lib can't do that. Iirc, there is other lib can do that. Or you may use the xdiff extension. https://www.php.net/manual/en/function.xdiff-string-patch.php I feel it should be too hard to implement it for unified diff. But I actually haven't written in PHP for years, now I am more of a Python dev. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Sorry if this is easy to do but I don't seen anything like this in the demo app.
My use case is fairly common, I think: I need to track edits made to text over time, so I want to store the latest version of some text with the reverse diffs that allow the reconstruction of any earlier version, by applying these diffs to the current text.
So my question is: given some old text and a diff, how can I apply that diff to the old text to produce the new text? I'm thinking of a function like this:
With a function like this, it's easy to regenerate any version of the text by applying the diffs. This is very storage-efficient.
Is this possible with your library?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions