Page MenuHomePhabricator

<del> tags causing paragraph break when used with a certain combination of headings, categories and links
Closed, ResolvedPublic

Description

A bit of a head-scratcher, this one.

If you save the following wikitext, it produces paragraph breaks between "bar", "baz" and "qux":

=== Example heading ===
[[Category:Foo]]
[[bar]]<del>baz</del>qux

Here's the generated HTML:

<h3><span class="mw-headline" id="Example_heading">Example heading</span></h3>
<p><a href="/wiki/Bar" title="Bar" class="mw-disambig">bar</a></p>
<del>baz</del>
<p>qux</p>

I'd expect "foo", "bar" and "baz" to be inside the same <p></p> tags. This behaviour is fragile, as well. If you remove the heading, or the category, or stop "bar" from being a link, or use <s></s> tags instead of <del></del> tags, "foo", "bar" and "baz" all appear in the same set of <p></p> tags as expected.

This was also reported on enwiki's village pump here (permanent link).

Event Timeline

MrStradivarius raised the priority of this task from to Needs Triage.
MrStradivarius updated the task description. (Show Details)
MrStradivarius subscribed.

Another example reported at https://en.wikipedia.org/wiki/Template_talk:Rfc#Formatting_bug:

{|
|}
[[Category:X1]]
[[Wikilink]] <del>redacted</del>

This produces:

<table>
<tr>
<td></td>
</tr>
</table>
<p><a href="/wiki/Wikilink" title="Wikilink" class="mw-redirect">Wikilink</a></p>
<del>redacted</del>

Also, the bug didn't appear when I used Special:ExpandTemplates with the two wikitext examples above. It only seems to happen on the live site.

After more testing, it seems that the top-most wikitext can be any wikitext that produces a block-level element. This code also triggers the bug:

<div>Block-level</div>
[[Category:Foo]]
[[bar]]<del>baz</del>

This is tidy cleaning up. It does this probably due to the exceptional paragraphing behavior of ins and del described in the spec: https://html.spec.whatwg.org/multipage/semantics.html#edits-and-paragraphs

Let's hope T89331 can help....

Tidy's enclose-text and enclose-block-text options both do this.

Aklapper triaged this task as Lowest priority.Apr 13 2015, 9:06 AM
Izno claimed this task.
Izno subscribed.

Fixed by Remex. Tested the first two examples.