I've been looking into including a system to allow logging of diffs so
users can view different versions of a file and roll it back to an
earlier version. After a lot of faffing with PHP diff functions and
the like I'm thinking that the best way to do it is probably just to
pass the data to the UNIX diff() program to get the diffs for the edit
and use patch() for the rolling back.
Unfortunately there's nothing that stops users entering just a single
long line of markup, and as diff appears to be line-based this means
the generated patches would be very space inefficient. I thought of
running the user input through wordwrap() before committing it but
that's problematic because it can split a HTML tag across lines.
What I need is at least a wordwrap() that takes HTML markup into
account, and I think that maybe some kind of HTML pretty printer would
be better.
Can anyone help with this?