Diff over history
As history is currently displayed, it's easy to see the full post at any time in the past, but determining what has changed requires scrolling back and forth through the history. It would be nice to get a diff instead. I am thinking of something like Stack Overflow's diff feature, which is a character-level diff (good for prose), but a traditional line-level diff might be useful for any code/scripts we might post.
Most of the time this will be a diff between the current version and some version in the past (given the 1-second quiescence history granularity, generally not the immediately previous revision), so we may not need diffs between arbitrary versions.
Definitely. What do you think would be a good UI? History mode already has its own buttons (currently, just Stop History), so we could add a toggle button between Diff Mode and Show-Full-Version Mode (in svn this is called svn cat...). And I guess a user setting for which is the default?
The slider widget I'm using has support for selecting a range, meaning you could actually have a reasonable interface for diffs between arbitrary versions. The question is, would that be useful? I'm not sure... though it would make it visually clear which of the two modes you're in.
For raw view, we can use the current text-based diff package. For formatted view, we might want to do an HTML diff on the formatted HTML.
- [ ] We should implement raw diffs first (and automatically switch to raw diff mode), until we figure out HTML diff.
What about a button/option to make the history bar "sticky" (always showing on top of the browser window)? This would allow to scroll down a post and navigating back in forth in the history while seeing the corresponding text.
I think that could be a reasonable (and probably simpler) alternative to the diff-ing issues mentioned here and in #89 .
Thoughts?
Possible plan for diffing rendered HTML:
- Parse HTML
- Split HTML into sequence of lines of the form
<tag attributes>,text, or</tag> - Run standard line-based diff algorithm
- Map these changed lines back to changed nodes in the tree
- Identify shared subtrees that have no diffs within them
- Render changed subtrees, ancestors, and maybe 1 sibling (at each level?) for context, with before version above after version
- Render changed text nodes specially (omit large chunks of unchanged text, using another level of diff)
Another application for diffing: since view could display/highlight what's changed since the specified time.
Wouhou! Cool to see some progress on that issue :-)