Skip to content

HTML output ignoring new line diff? #110

@ablce9

Description

@ablce9

Hi, first of all we really appreciate all of efforts diffy contributors are putting. Our product can not be thrived without diffy!

We have been noticing an unexpected behavior when comparing a text with a text containing a newline at end of file with HTML format like so:

[47] pry(main)> out = Diffy::SplitDiff.new("aaaaaaaaaa\n", "aaaaaaaaaa", format: :html, allow_empty_diff: false)
=> #<Diffy::SplitDiff:0x0000561b1cb964e0 @diff="<div class=\"diff\"></div>", @format=:html, @left_diff="<div class=\"diff\"></div>", @right_diff="<div class=\"diff\"></div>">
[48] pry(main)> out.right
=> "<div class=\"diff\"></div>"
[49] pry(main)> out.left
=> "<div class=\"diff\"></div>"
[50] pry(main)>

This is like saying there is no diffs even though left text does end with \n . Most importantly, characters disappear!

However, in TEXT format output is a bit different than that like so:

[45] pry(main)> Diffy::SplitDiff.new("aaaaaaaaaa\n", "aaaaaaaaaa", format: :text, allow_empty_diff: false)
=> #<Diffy::SplitDiff:0x0000561b1cb42660
 @diff="-aaaaaaaaaa\n" + "+aaaaaaaaaa\n" + "\\ No newline at end of file\n",
 @format=:text,
 @left_diff="-aaaaaaaaaa\n" + "\\ No newline at end of file\n",
 @right_diff="+aaaaaaaaaa\n" + "\\ No newline at end of file\n">

As you can see, both left and right diff are processed in text format, nicely denoting that No newline at end of file. We would expect the same, not empty html tags but actual newline diff with html tags.

Before specifying this kind of behavior is a bug, we would like to know this(comparing with a text with newline in HTML format) is expected or not.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions