Page MenuHomePhabricator

Allow Scribunto code to add a category without changing output
Open, Needs TriagePublic


Sometimes Lua module is used with some obsolete parameters, and wants to create a category for all pages that use it in obsolete way. Other times Lua might simply want to add a category to the page. Regardless, adding "[[category:xxx]]" to the output is not ideal because there are many cases when it breaks final wiki markup (e.g. in the middle of the html atribute text.

I think there should be a frame::addCategory()

Event Timeline

Yurik created this task.Jun 10 2016, 5:50 PM
Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptJun 10 2016, 5:50 PM
Rical added a subscriber: Rical.Sep 6 2017, 2:52 PM

To solve this question in central modules, I collect all categories in a table.
Then, just before return the wikitext, I place them after this wikitext.

Anomie added a comment.Sep 6 2017, 3:22 PM

To solve this question in central modules,

Which is entirely irrelevant to this task.

Rical added a comment.Sep 6 2017, 5:07 PM

To delay categories at the end of the wikitext is a simple way.
If this way answer the question, is this task needed?

How frame::addCategory() can solve the question if it is in the same place in the html page?

Anomie added a comment.Sep 6 2017, 5:27 PM

That way is not the answer to the question. The method would probably be mw.addCategory() rather than being on the frame object, and would call $parserOutput->addCategory() rather than doing anything to the wikitext.

Collecting categories in a table as you go, and spitting the table out at the end of your output, is a workaround, and probably one of the most elegant workarounds, absent any other tools. Having some tool specifically for the job is probably preferable though (especially since it means editors don't have to be aware of the problem and its potential workarounds).