php-diff icon indicating copy to clipboard operation
php-diff copied to clipboard

Fix multiple space rendering

Open adipose opened this issue 5 years ago • 4 comments

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.

adipose avatar Nov 07 '19 17:11 adipose

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.

jfcherng avatar Nov 07 '19 18:11 jfcherng

Well, I did check your branch and you avoided that bug by using matches[0] and no capture group. :)

adipose avatar Nov 07 '19 19:11 adipose

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

jfcherng avatar Nov 08 '19 09:11 jfcherng

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

JBlond avatar Mar 07 '20 21:03 JBlond