Page MenuHomePhabricator

html of table.diff cells contains terminal white-space not in source text
Closed, ResolvedPublic

Description

Author: M8R-cyc3n3

Description:
i set this in my personal css to make my diff view resemble the editform,
namely to make the number and type of spaces apparent in each line.

.diff-addedline, .diff-deletedline, .diff-context

{ font-family:monospace; white-space:pre-wrap; }

but i did not count on the html of these cells containing superfluous carriage
returns and spaces. due to my css, the \n's became visible as blank lines at
the start and end of each cell and two extra spaces appeared at the end.

i.e. "CONTENT" is represented as "\nCONTENT\n ".

see, the outputted html looks like this:

<td class="diff-deletedline"><div>

FIVE→ ←SPACES

</div></td>

whereas the following would be ideal:

<td class="diff-deletedline"><div>FIVE→     ←SPACES</div></td>

of course, all white-space actually present in each line of wiki-text should
remain so.

(i don't know the purpose of adding a div tag with no attributes to each cell,
but that's another matter.)


Version: 1.20.x
Severity: normal

Details

Reference
bz28988

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:32 PM
bzimport set Reference to bz28988.

The div is there to make the CSS overflow work, so the table doesn't get pushed wider than the screen when there are very long lines.

The spaces seem to just be general HTML pretty-printing indentation, which you'll find in many many places (but not always consistently). This may also depend on which diff engine is producing the diff, and whether or how tidy is being used.

I don't see any unusual spaces offhand on a random diff on mediawiki.org, which I think'll be using the wikidiff2 plugin. Can you provide a URL to a diff page which exhibits this problem and confirm which mode it's using?

Maybe bug 25725? Need only recompile on wmf wikis (bug 27720).

M8R-cyc3n3 wrote:

example diff url:
http://en.wikipedia.org/w/index.php?oldid=428860852&diff=prev

screen-shot with css rules: font-family:monospace; white-space:pre-wrap;
applied, causing affected cells to occupy three lines (not good).
http://i52.tinypic.com/2lx7z87.png

offending html highlighted here:
http://i51.tinypic.com/2yw9sgn.png

note the gray cells (td.diff-context) do not exhibit the same problem.

Looks like that's it yeah -- I've added a dep on bug 27720, needs to coordinate w/ ops to make sure the package is updated.

Might also need something to expire cached diffs? I'm not sure if those are perma-cached or just 24h right now.

Please test, depending bug 27720 is fixed.