4

I'm looking for the best way to compare n chunks of HTML and show the rendered changes over time, essentially recalling versions of a page in a CMS and listing the changes for users.

While 1061468 and 31722 are useful, they don't really address this need.

I'm not after a solution that has a pretty display, visually indicating the changes. I just want want data - in an ideal world I'd pass an array or object containing n blocks of html in chronological order and get back an object of either version-to-version or cumulative changes

I realise that this is one of those 'The more you look at it, the more difficult it appears' questions. Clearly any change to 'content' would have to be picked up but relevant mark-up is far more difficult to identify - you can have huge change that makes no difference to rendered content and tiny change that alters the page dramatically.

To be honest, I'm not even sure that what I'm looking for is practical at all. But before I give up on this as a path to investigate, I thought I'd ask the crowd.

Community
  • 1
  • 1
PerryW
  • 1,426
  • 1
  • 15
  • 25
  • 1
    You might consider the approach of rendering the different versions, saving the result as an image and comparing the images programmatically. There are probably some software packages that do image diffs. But even just fading between the two images of the rendered versions might be instructive. – Nathaniel Granor Jul 08 '13 at 02:39
  • Do you insist on comparing the *rendered* versions, or are you happy with comparing the HTML? If you insist on comparing the rendered versions, how do you expect to get them as objects with structure (so you can do a meaningful structural comparison) rather than just rendered pixels? It seems to do the latter, you have to tap into each specific's browser dom-rendering pipeline. Otherwise you need to simulate the rendering, completely, for HTML, and intercepting it just before pixels are rendered and that's a tall order. – Ira Baxter Jul 08 '13 at 04:08
  • It certainly is a tall order - I'm not sure that it's possible. A visual image comparison for the end user isn't going to to work - there may be 2, 5 or even 10 revisions of the page. Imagine Word's track changes capability where changes to the document over time are highlighted with some simple metadata. That's closer to what I'm looking for. I started to have a go myself but it all became too difficult. Posted here in case anyone on the SO community had seen something similar – PerryW Jul 09 '13 at 01:37
  • For a CMS Version Control System it might be good enough to just show thumbnail screenshots of the different systems. I doubt anybody expects more. – Lothar May 26 '17 at 02:08

0 Answers0