differ icon indicating copy to clipboard operation
differ copied to clipboard

Something is wrong when there is bold text

Open krzkrzkrz opened this issue 14 years ago • 2 comments

Something is wrong when there is bold text (text surrounded by the <strong> element). Take for example:

a = "<p>adfadf<br>\n222<br>\nfoo <strong>bar</strong> was <code>here</code> 333<br>\nhere too<br>\n444<br>\n55 <strong>bold text added</strong><br>\n66</p>\n"
b = "<p>adfadf<br>\n222<br>\nfoo <strong>bar</strong> was <code>here</code> 333<br>\nhere too<br>\n444<br>\n55<br>\n66</p>\n"
Differ.diff_by_word(a, b).format_as(:html).html_safe

The following renders as:

<p>adfadf<br>
222<br>
foo <strong>bar</strong> was <code>here</code> 333<br>
here too<br>
444<br>
55<del class="differ">&lt;</del><ins class="differ"> <strong>bold text added</strong>&lt;</ins>br&gt;
66</p>

Notice the &lt; characters. Is this normal? Which renders in the browser inappropriately...

krzkrzkrz avatar Sep 21 '11 22:09 krzkrzkrz

This is fixed if I do diff by line, and not by word. Strange...

krzkrzkrz avatar Sep 22 '11 02:09 krzkrzkrz

It's not designed to be HTML-aware and diffs raw strings. So, tags might be unmatched, or even cut in the middle, this is normal. Outputting source tags as-is in html output is probably a bug: #15.

kolen avatar Jun 29 '20 14:06 kolen