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

Diff of bold, italic, underline and strikethrough differs

Open qstiegler opened this issue 6 years ago • 5 comments

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.

qstiegler avatar Jun 04 '19 08:06 qstiegler

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

SavageTiger avatar Jan 19 '22 11:01 SavageTiger

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.

ghry5 avatar Jun 07 '22 08:06 ghry5

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

SavageTiger avatar Jun 08 '22 14:06 SavageTiger

  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>

ghry5 avatar Jun 08 '22 14:06 ghry5

@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

SavageTiger avatar Jun 11 '22 10:06 SavageTiger