The approach in MobileFrontend looks for a paragraph and an infobox (where infobox now includes block images since T258201), and switches them around. This approach requires us to list the likely types of block elements that could come before a paragraph, and our current filter of class=infobox|thumb is not exhaustive. Many images are wrapped in various containers (T261993) and there are other types of block elements we would want to move down.
The approach in mobile apps[1][2] just moves the lead paragraph (and all siblings up to the next paragraph) to the top of the page, regardless of what is above it. It then only has to detect templates at the top of the page which should stay at the top, currently this is just class=hatnote. For MF we should probably also include class=mbox and others we are aware of (mboxes are just hidden in mobile apps, hence not included in their code).
1. https://github.com/wikimedia/mobileapps/blob/e858d09962aa9c0e9a0b04bdbed36c18f973aeb5/lib/mobile/MobileHTML.js
2. https://github.com/wikimedia/mobileapps/blob/43c2b2f66641ebf58a0cc1ebf885e361f0ea68f0/pagelib/src/transform/LeadIntroductionTransform.js
== QA
For as many pages in the list of candidate pages below:
# Visit the page on enwiki and on [[ https://patchdemo.wmflabs.org/wikis/e12ceee710c86b511d301b6164eda9e4/w/index.php/?toggle_action_mobile | this patchdemo ]]
** e.g. https://en.m.wikipedia.org/wiki/Foo and https://patchdemo.wmflabs.org/wikis/e12ceee710c86b511d301b6164eda9e4/w/index.php/Foo?mobileaction=toggle_view_mobile
# Check that the lead paragraph remains at the top of the page or that it has moved to the top of the page
# On https://it.m.wikipedia.org/wiki/Organo_a_pompa there are two hat notes, one with the hatnote class and the other an ambox. Both templates are using TemplateStyles which could be related. Make sure the hatnotes are hoisted.
=== List of candidate pages
- https://en.m.wikipedia.org/w/index.php?title=Tone_letter&oldid=975330311
- https://en.m.wikipedia.org/w/index.php?title=Al_Messila_(Doha)&oldid=966542034
- https://en.m.wikipedia.org/w/index.php?title=Proceedings_of_the_Royal_Irish_Academy&oldid=958366725
- https://en.m.wikipedia.org/w/index.php?title=Al_Jihad_fil_Islam&oldid=973512057
- https://it.m.wikipedia.org/w/index.php?title=Organo_a_pompa&oldid=113765766
- Any of https://pageviews.toolforge.org/topviews/?project=en.wikipedia.org&platform=all-access&date=last-month&excludes=
== QA Results - Beta
| **AC** | **Status** | **Details** |
| ----- | ----- | ----- |
| 1 | ✅ | T262093#6896451 |