Context
MobileFormatter is responsible for, among other things, sectionifying the document.
It's covered in unit tests but its documentation is lacking. Moreover, the configuration variable that affects the sectionifying behaviour the most isn't self-documenting.
$wgMFMobileFormatterHeadings allows an administrator to specify the following:
- The rank of heading that starts a new section.
- The ranks of headings that should be marked as editable.
$wgMFMobileFormatterHeadings = [ 'h2', 'h3', 'h4' ];
For example, the above should be read as follows:
Second rank headings, i.e. h2 elements, start new sections and h2, h3, and h4 elements should be marked as editable.
My recommendation would be to deprecate $wgMFMobileFormatterHeadings in favour of:
- string $wgMFTopLevelSectionHeading = 'h2';
- string[] $wgMFEditableSectionHeadings = [ 'h2', 'h3', 'h4' ];
Open Questions
- Just what is the in-block CSS class for? [The headings specified by $wgMFMobileFormatterHeadings are tagged with the in-block CSS class is about as much as I know](https://github.com/wikimedia/mediawiki-extensions-MobileFrontend/blob/master/includes/MobileFormatter.php#L541-L542). However, the creation of the edit icon is handled in SkinMinerva#doEditSectionLink, which doesn't reference $wgMFMobileFormatterHeadings!
- Why does the MobileFormatter add edit links? e.g. <a class="edit-page" href="#editor/2">Edit</a> - shouldn't this be the duty of the skin?
AC
- There is a top-level document, i.e. docs/sectionifying.{txt,md,wikitext}, describing this behaviour.
- $wgMobileFormatterHeadings is deprecated in favour of $wgMFCollapsibleSectionHeading and $wgMFEditableSectionHeadings.
- If $wgMFEditableSectionHeadings is set in LocalSettings.php, then its value is not modified (see T146918#2768110 and T146918#2689252).
- The in-block class is renamed to in-collapsible-section
- in-collapsible-section is a provisional name.
- PENDING Sections that are marked as editable are tagged with the is-editable CSS class.
Original Task
Visiting https://en.m.wikipedia.org/wiki/President_of_Republika_Srpska you'll see an in-block class on h2 elements. This should only apply to headings inside a given section.
Looking closely it seems that the value of MFMobileFormatterHeadings is merging incorrectly.
Defining
$wgMFMobileFormatterHeadings = array( 'h2', 'h3', 'h4', 'h5', 'h6' );
... in LocalSettings.php will yield the value
array(11) { [0]=> string(2) "h1" [1]=> string(2) "h2" [2]=> string(2) "h3" [3]=> string(2) "h4" [4]=> string(2) "h5" [5]=> string(2) "h6" [6]=> string(2) "h2" [7]=> string(2) "h3" [8]=> string(2) "h4" [9]=> string(2) "h5" [10]=> string(2) "h6" }
I suspect this is related to the move to extension.json but it's an array so I'm not sure what's happening here.