Last modified: 2014-03-18 03:07:55 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T41066, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 39066 - Closing a block-level element that contains a list at the end of the last list item generates invalid HTML
Closing a block-level element that contains a list at the end of the last lis...
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
unspecified
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
http://yugioh.wikia.com/wiki/User:Din...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-06 03:09 UTC by Phillip Patriakeas
Modified: 2014-03-18 03:07 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Phillip Patriakeas 2012-08-06 03:09:39 UTC
On wikis without HTML Tidy installed/activated, when a div containing a list has the div's closing tag placed at the end of the last item in the list, the parser puts the </div> before the </[li|dt|dd]></[ul|ol|dl]> tags. For instance, the following markup:

<div>
* This
* is
* a
* list.</div>

results in the following HTML:

<div>
<ul><li> This
</li><li> is
</li><li> a
</li><li> list.</div>
</li></ul>

By comparison, closing the div on the line following the last list item results in valid markup being generated:

<div>
* This
* is
* a
* list.
</div>

results in:

<div>
<ul><li> This
</li><li> is
</li><li> a
</li><li> list.
</li></ul>
</div>

This is a problem e.g. on hlists in navboxes, where the list of links can easily be longer than the navbox is wide. In this case, it seems to prevent the list from wrapping, instead forcing the navbox to stretch to the length of the entire list.
Comment 1 Phillip Patriakeas 2012-08-06 21:18:13 UTC
In the specific case of navboxes, the closing markup for the list item (and the list overall) ends up following the markup generated to close the containing table cell and row and open the following row/cell. If the cell containing the list is the last one in the table, the closing list markup instead follows the closing table markup.

An example can be seen at http://yugioh.wikia.com/wiki/User:Dinoguy1000/sandbox?oldid=2041433
Comment 2 Phillip Patriakeas 2012-08-06 21:26:07 UTC
Per http://yugioh.wikia.com/wiki/User:Dinoguy1000/sandbox?oldid=2041434 this seems to be caused by any block-level element, not just divs.
Comment 3 Erwin Dokter 2012-09-16 09:02:07 UTC
Probably related: Bug 40274 and Bug 39617.
Comment 4 Brad Jorsch 2013-04-09 16:02:05 UTC
Why are you trying to close the block element inside the list item? When you give the parser poorly-formatted wikitext, don't be surprised when it gives you back invalid HTML.

I'm inclined to close this as INVALID.
Comment 5 Phillip Patriakeas 2013-04-09 16:51:44 UTC
It would be INVALID (maybe) if this bug were about closing the containing block-level element on any of the list items other than the last one. It is not, though; this bug pertains specifically to closing the block-level element at the end of the *last* list item, which should by all accounts result in valid markup. The fact that it doesn't is counter-intuitive and breaks several Wikipedia templates when imported to wikis without HTML Tidy enabled. While that could potentially be fixed by correcting the offending templates (and that's assuming they *can* be fixed; there's no guarantee it would be possible without a major overhaul in some cases), it is by no means reasonable to expect reusers to realize there's a problem, identify the cause, and either fix their local copy or (preferably) request a fix on Wikipedia's copy.
Comment 6 Brad Jorsch 2013-04-09 17:37:50 UTC
What's special about the last one that you should be able to close outer block elements inside it? And what "accounts" tell you it should result in valid markup?

Consider what happens when you have a template containing your example, and then you start another list right after it:

{{comment1}}
* Foo
* Bar

Expands to

<div>
* This
* is
* a
* list.</div>
* Foo
* Bar

Suddenly your "last element" isn't the last element anymore. And this confuses Tidy too; see [[Template talk:Shortcut#Changing wiki-markup to pure HTML in lists]] on enwiki, for example.
Comment 7 Phillip Patriakeas 2013-04-09 17:53:43 UTC
>What's special about the last one that you should be able to close outer block
elements inside it?
Nothing, actually, beyond that it's the last list item. Really, the ideal solution would be for the parser to end the list when it encounters the closing outer block element, and simply start a new list for any following list elements; this is certainly a better option than simply outputting broken markup (especially since the current solution requires breaking the list into two separate lists anyways).
Comment 8 Erwin Dokter 2013-09-01 10:24:22 UTC
A wiki list item should always be contained within its own line.

If for whatever reason other element tags are contained within that (last) line, it is invalid wiki markup. The template example does not produce the error you expect, because a template with a list usually terminates with a linebreak (otherwise, the template is badly coded).

There is only so much invalid wiki markup the parser can fix, so this is unlikely to be addressed. Closing as INVALID.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links