php-diff
php-diff copied to clipboard
Fix multiple space rendering
The code tries to replace multiple spaces with "nbsp; " and "nbsp;" depending on whether it is odd or even. The original preg_replace is only capturing the trailing spaces, but replacing all of them, which means the first space always gets silently dropped.
I would suggest you use a maintained fork rather than fixing a single issue. There are still many problems in this repo...
Such as
- https://github.com/jfcherng/php-diff (mine, rewritten with some API changed, new features)
- https://github.com/JBlond/php-diff (I think this is a fixed version of the current repo without functionality changed)
They all require PHP >= 7.1 though.
Well, I did check your branch and you avoided that bug by using matches[0] and no capture group. :)
Yes. No need to use capture group and the codes can be cleaner.
https://github.com/jfcherng/php-diff/blob/bc52a5a/src/Renderer/Html/AbstractHtml.php#L273-L284
Yes, my repo is the fix version of the current repo. The functions are the same plus a few new ones.
PR's are welcomed in my repo