Page MenuHomePhabricator

Transclusion of templates with tables inserts excess whitespace
Closed, ResolvedPublic

Description

Author: flamurai

Description:
In templates that consist of tables, every transclusion after the first inserts
excess whitespace in the form of <p><br /></p> above the transclusion.

Reduced test case: [[User:Flamurai/Transclusion]]

Real world example: [[Names of God in Judaism]]. The code is:

... use God's name in a similar fashion.
{{listen|filename=He-El.ogg|title=El|description=|format=[[Ogg]]}}

This produces the HTML:

use God's name in a similar fashion.</p>
<p><br /></p>
<table cellspacing="0" border="0" align="left" style="
margin-left: 0.5em; color: inherit; background-color: transparent; position:
relative; left: -8px;">
<tr style="vertical-align: top;">
<td rowspan="3" style="width: 30px; padding-right: 3px; padding-top: 4px;
vertical-align: top;">
...

That <p><br /></p> is producing excess whitespace.

However, the first time the template's included there's no problem with the code:

... sometimes used to refer to a distinguished person.
{{listen|filename=He-Adonai.ogg|title=Adonai|description=}}

Which results in:

... is sometimes used to refer to a distinguished person.</p>
<table cellspacing="0" border="0" align="left" style="
margin-left: 0.5em; color: inherit; background-color: transparent; position:
relative; left: -8px;">
<tr style="vertical-align: top;">
<td rowspan="3" style="width: 30px; padding-right: 3px; padding-top: 4px;
vertical-align: top;">

That extra paragraph is not there. This problem is also on [[History of music]].


Version: 1.4.x
Severity: normal
URL: http://en.wikipedia.org/wiki/User:Flamurai/Transclusion

Details

Reference
bz1598

Revisions and Commits

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:14 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz1598.
bzimport added a subscriber: Unknown Object (MLST).

zigger wrote:

See also bug 1343 and bug 1176.

flamurai wrote:

After checking the bug 1343 and bug 1176 and doing some further testing, I've
noticed a few things:

  1. This only applies to templates that are wikitables, not to divs, HTML tables,

etc.

  1. The same phenomenon happens every time for each separate template. That is,

if I use {{table1}} and {{table2}} multiple times, for each one, the first use
will be fine, and every use thereafter will have excess whitespace.

  1. If the template is the first element in the page, the problem is exactly the

opposite! There is whitespace before the first transclusion, but every
transclusion thereafter is fine.

I updated [[User:Flamurai/Transclusion]] to encompass all these cases.

flamurai wrote:

A temporary hack to fix this is to wrap the table in <div>...</div>, however the
parser bug should still be found and fixed.

avarab wrote:

Marking it as a duplicate of bug 1343, which I solved 3 days ago.

*** This bug has been marked as a duplicate of 1343 ***

Diffusion added a commit: Unknown Object (Diffusion Commit).Mar 4 2015, 8:22 AM