Page MenuHomePhabricator

#subpagelist: Incorrect HTML code.
Closed, ResolvedPublic

Description

Author: van.de.bugger

Description:
{{ MediaWiki-extensions-SubPageList: page=page | kidsonly=yes }}XX

generates code:

<div class="subpagelist">
<ul><li><a href="...">Subpage1</a>
</li><li><a href="...">Subpage2</a></div>XX
</li></ul>

Note intersection between div and ul: <div><ul></div></ul>. That's incorrect. must be <div><ul></ul></div>.

The problem is in makeList' function and MediaWiki parser. MediaWiki parsers thinks a list item is finished by newline; while makeList' function adds newline /before/ each item, and omits newline after the last item of the list.


Version: unspecified
Severity: normal

Details

Reference
bz32131

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 12:06 AM
bzimport set Reference to bz32131.

van.de.bugger wrote:

Bug fix.

Attached:

Is this a patch against trunk? And can you please not change var names all over the place and make a functional change at the same time? This makes it quite hard to review.

I honestly don't see where the current code is wrong, and how your patch fixes it.

van.de.bugger wrote:

Is this a patch against trunk?

Yes.

And can you please not change var names all over

the place and make a functional change at the same time?

I change var name because the meaning of the variable is changed. I do not think it would be helpful to use $start variable for a character used for finishing list item. This is exact reason why I named it $itemFinish.

I honestly don't see where the current code is wrong, and how your patch fixes

it.

Let us consider lists of ul or ol types. makeList generates a newline at the front of each list item, and DOES NOT generate newline at the end of the last item, so result (before pass it to parseWikitext) will be

intro...<div>

  • item1
  • item2</div>outro

Mwdiawiki parser allows </div>, but does not understand that </div> terminates the item, and generates

intro...<div>
<ul><li>item1
</li><li>item2</div>outro
</li><ul>

The problem can be solved by adding newline after the end of last item of the list:

intro...<div>

  • item1
  • item2<!-- This newline solves the issue. -->

</div>outro

So parser will generate

intro...<div>
<ul><li>item1
</li><li>item2
</li><ul>
</div>outro

van.de.bugger wrote:

Alternative fix.

Alternative fix. May be it would be easier to understand.

Attached:

Oh.. So it's the parser messing it up - that explains why I did not see anything wrong :)

Will apply your patch later today - thnx!

van.de.bugger wrote:

Verified on r102853.