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

Diff of bold, italic, underline and strikethrough differs #85

Open qstiegler opened 5 years ago

qstiegler commented 5 years ago

If you compare <p>This is a text</p> with the same text in bold <p><strong>This is a text</strong></p>, the result is <p><del class="diffmod">This is a text</del><strong class="diffmod"><ins class="mod"><ins class="diffmod">This is a text</ins></ins></strong></p>

If you compare <p>This is a text</p> with the same text in italic <p><em>This is a text</em></p>, the result is <p><del class="diffmod">This is a text</del><em class="diffmod"><ins class="diffmod">This is a text</ins></em></p>

If you compare <p>This is a text</p> with the same text underlined <p><u>This is a text</u></p>, the result is <p><u class="diffmod"><ins class="mod">This is a text</ins></u></p>

If you compare <p>This is a text</p> with the same text struck through <p><u>This is a text</u></p>, the result is <p><s class="diffmod"><ins class="mod">This is a text</ins></s></p>

I'm not 100% sure whats the correct way but it should be the same for all of them. I'm not able to style the diff properly.

SavageTiger commented 2 years ago

Could you check if this problem still persist in the latest version?

ghry5 commented 2 years ago

I can confirm that this problem still exists in the latest version. For <em> and <strong> The diff contains deleting the text and reinserting it in the corresponding tag. For <u> and <s> the diff only adds the diffmod class to the corresponding tag.

SavageTiger commented 2 years ago

@ghry5 Would you have a left and right text and an expected and actual result? that would make this easier to reproduce.

ghry5 commented 2 years ago
  1. <strong> left: <p>This is a text</p> right: <p><strong>This is a text</strong></p> actual: <p><del class="diffmod">This is a text</del><strong class="diffmod"><ins class="diffmod">This is a text</ins></strong></p> expected: <p><strong class="diffmod">This is a text</strong></p>

  2. <em> left: <p>This is a text</p> right: <p><em>This is a text</em></p> actual: <p><del class="diffmod">This is a text</del><em class="diffmod"><ins class="diffmod">This is a text</ins></em></p> expected: <p><em class="diffmod">This is a text</em></p>

As an example following <u> and <s> cases to show how i expect it to be:

  1. <u> left: <p>This is a text</p> right: <p><u>This is a text</u></p> actual: <p><u class="diffmod">This is a text</u></p>

  2. <s> left: <p>This is a text</p> right: <p><s>This is a text</s></p> actual: <p><s class="diffmod">This is a text</s></p>

SavageTiger commented 2 years ago

@ghry5 (cc: @qstiegler) I looked into this issue today and found out that its because of the isolatedDiffTags in the config, strong is in that list s is not for example.

Its always scary to change these types of things, since it means that output will change after an update.

After thinking about it a bit I think the best thing to-do here is to remove the text-styling tags from that list, and just keep the element tags (such as sup and table).

Meaning that the changes of styling can be styled by making a css class for diffstyle