Page MenuHomePhabricator

plwiktionary: Gadget:hide-empty-fields needs a Parsoid-specific tweak
Closed, ResolvedPublic

Description

https://pl.wiktionary.org/wiki/MediaWiki:Gadget-hide-empty-fields.js is hiding non-empty fields for Parsoid content. Ex;: on this page, the "warianty" text inside a dl-list is hidden.

In this section of the code, line 42 is not working in the case of Parsoid because of the presence of a about-wrapped span that wraps a newline. So, instead of the check hitting a table (by skipping over whitespace), it encounters a span and decides it is an empty dl without a definition term (dd). So, that check needs to be tweaked to deal with template-wrapped spans around newlines.

The Parsoid HTML in question is:

<dl about="#mwt6"><dt><span class="field field-title fld-warianty field-foreign" data-field="warianty" data-section-links="foreign">variants<span typeof="mw:Entity">:</span></span></dt><dd></dd></dl><span about="#mwt6">
</span><table about="#mwt6">

vs the legacy HTML which is:

<dl><dt><span class="field field-title fld-warianty field-foreign" data-field="warianty" data-section-links="foreign">variants&#58;</span></dt>
<dd></dd></dl>
<table>

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
ssastry renamed this task from plwiktionary: Gadget:hide-empty-fiels needs a Parsoid-specific tweak to plwiktionary: Gadget:hide-empty-fields needs a Parsoid-specific tweak.Feb 13 2025, 3:47 PM

Fixed both in the main gadget and its mobile counterpart, hoping this additional check won't be too expensive. It would be best to get rid of that newline from the {{warianty}} and {{słowniki}} templates in the first place, but I am not sure it is possible at all (per the related task).