caxy / php-htmldiff

A library for comparing two HTML files/snippets and highlighting the differences using simple HTML. Includes support for comparing complex lists and tables
http://php-htmldiff.caxy.com
GNU General Public License v2.0
202 stars 51 forks source link

Add spaceMatching setting that matches all spaces #111

Closed berarma closed 11 months ago

berarma commented 2 years ago

This feature tries to provide a fix for #109. It adds a setting spaceMatching which can be set to true so spaces aren't ignored at all.

The HTML provided needs to have the meaningless spaces removed beforehand so only the spaces that we want to compare are present. I think this is more easily done by the developer using the library since it knows more about the HTML being used. The case were I want to apply it is for the code generated by a HTML editor that allows a limited set of tags with predefined layout behavior.

I've added some test cases. I haven't tested the code out of these test cases but I think it will serve my purposes well. I've created the PR so it makies its way while I get to implement it on my project. I might have overlooked something and the naming could probably be better so please make suggestions.

Thanks.