Module:Hatnote group/doc: Difference between revisions
More actions
Created page with "<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see Wikipedia:Wikidata) --> Implements {{tl|hatnote group}}, for merging multiple hatnotes into a grouped hatnote. ==Technical details== The module attempts to find each hatnote-looking <code>div</code> element, and parse them into space-separated <code>span</code> elements wrapped in a larger, generic hatnote. First, it matches every pattern that "looks like a hatno..." |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{doc sub}} | |||
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | ||
Implements {{tl|hatnote group}}, for merging multiple hatnotes into a grouped hatnote. | Implements {{tl|hatnote group}}, for merging multiple hatnotes into a grouped hatnote. | ||
Line 17: | Line 18: | ||
<includeonly>{{sandbox other|| | <includeonly>{{sandbox other|| | ||
<!-- Categories below this line, please; interwikis at Wikidata --> | <!-- Categories below this line, please; interwikis at Wikidata --> | ||
[[Category:Modules]] | |||
[[Category:Hatnote modules| ]] | [[Category:Hatnote modules| ]] | ||
}}</includeonly><noinclude> | }}</includeonly><noinclude> | ||
[[Category:Module | [[Category:Module documents]] | ||
</noinclude> | </noinclude> |
Latest revision as of 02:53, 12 March 2025
This is a documentation subpage for Module:Hatnote group. It may contain usage information, categories and other content that is not part of the original module page. |
Implements {{hatnote group}}, for merging multiple hatnotes into a grouped hatnote.
Technical details
The module attempts to find each hatnote-looking div
element, and parse them into space-separated span
elements wrapped in a larger, generic hatnote.
First, it matches every pattern that "looks like a hatnote" in its input text; this is where most problems are likely to originate as the pattern is fairly sensitive to any difference in the form of a hatnote.
From each of the pattern matches, it constructs a table. Each element ("row") of the table corresponds to one original hatnote, and is a table that contains a string with the rendered inner content of the hatnote, and an inner table containing any "extra" classes associated with that hatnote (e.g. selfreference
from a {{self reference}} hatnote, or any classes from the extraclasses
parameter of {{hatnote}}).
It also separately looks for all categories in case they're present outside the hatnote div
element, and adds them to a concatenated string of all "loose categories" to make sure they're not accidentally removed by the hatnote grouping process.
Once all rows are available, it looks at the tables of classes. It adds every class from every row into a table of "universal" classes, then filters out the ones that aren't universal by looking at each row's list and eliminating an item if it isn't present in any one row. Then, "universal" classes are removed from each row's classes table, so that they're not duplicated later.
This processing having been done, each row is formatted with a span
element that includes the extra classes associated with that row, the spans
for each row are joined as a space-separated list, the "loose categories" are tacked on in turn, and then the resulting string is fed into the main hatnote module, with extra classes on the main hatnote being supplied by collating the "universal classes" table into a space-separated list of its keys.