Page MenuHomePhabricator

Single newlines sometimes create paragraphs
Closed, DuplicatePublic

Description

Tutorials like mw:Help:Formatting state that a single new-line will have no effect, however, that is not always the case. Single new-lines after block-level HTML elements might result in unnecessary <p> tags being created: while <div>foo</div> results in just that, <div>\nfoo\n</div> will result in <div><p>foo</p></div>. This can be very confusing because some CSS attributes of the div tag will have no effect (they will be overwritten by <p> rules in some CSS file). See the link for an example.


Version: unspecified
Severity: minor
URL: https://hu.wikipedia.org/wiki/User:Tgr/p

Details

Reference
bz9207

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:39 PM
bzimport set Reference to bz9207.

It is worse than it seemed: two line breaks *anywhere in the text* will cause a
<p> and a </p> to appear at the line breaks.

The following will appear unchanged in the rendered page:

<div>A B C</div>

This, however:

<div>A
B
C</div>

will appear in the output as

<div>A
<p>B</p>
C</div>

See [[hu:User:Tgr/p]] for a test case.

psychomessiah wrote:

However, it seems like

<div>
A
B
C
</div>

will result in

<div>A B C</div>

It's an important bug, I wonder why there is as little activity.

ayg wrote:

Because 1) it's not important, it's not just rare but often unnoticeable when it occurs, and 2) mucking with our atrocity of a parser is not something anyone wants to do.

psychomessiah wrote:

  1. It was important for me ;-) For the anecdote, I used to make a very simple template, who takes one or more paragraphs, and displays them with a <span> at the beginning, surrounded by a <div> :

<div><span>foobar</span> - {{{1}}}</div>
which, with the first parameter
A \n B \n C
results in
<div><span>foobar</span> - A
<p>B
</p>
C</div>
which isn't unnoticeable at all. If I hadn't asked for help in Wikipedia-fr, I'd never know that leaving a newline after the <div> and before the </div> will fix this. In fact, it's above all surprising.

  1. That's an argument, which I can easily understand ;-)

Note: This is partially (?) a duplicate of bug #5718

Punting this to the new parser Brion has under development.

  • Bug 53043 has been marked as a duplicate of this bug. ***