paulfitz/daff

--output-format html in python does not show line breaks in cell

Godsmith opened this issue · 2 comments

csv1.csv:

1,2,3,4,5
a,b,c,d,e

csv2.csv:

1,2,3,4,5
a,b,c,"d

linebreaks

",e

Running daff for python normally works (though the "5" is in a peculiar position):

13:19 $ daff csv1.csv csv2.csv
@@,1,2,3,4                        ,5
→ ,a,b,c,"d→d 

linebreaks 

",e

However, daff csv1.csv csv2.csv --output-format html > test.html gives the following:

image

I notice that line breaks seem to be working correctly in the Live example on http://paulfitz.github.io/daff/ (if you insert a line break in a cell by pressing alt+enter), so this might be a python-specific bug?

Looking at the generated HTML file, the line breaks are actually there, but as it is HTML they are not shown. I solved it by changing the CSS for the table cells:

.highlighter td {
  empty-cells: show;
  white-space: pre-wrap;
}

Don't know if this is the best solution though.

Thanks for reporting this @Godsmith. Your css tweak looks like a definite improvement. Not sure exactly how best to show newlines in general. Maybe showing paragraph symbol "¶"?

Awesome, thank you!

Not sure what you mean about how to show newlines. I would like newlines to show as newlines. (-: