Page MenuHomePhabricator

The #categorytree magic word doesn't seem to work in VisualEditor
Closed, ResolvedPublic

Description

The #categorytree magic word doesn't seem to work in VisualEditor and Parsoid.

If I have an article in the English Wikipedia that has the wikitext {{#categorytree:ASCII}}, VisualEditor shows it like this:

Screenshot_2020-07-07 Editing ASCII - Wikipedia.png (196×1 px, 52 KB)

Similar output appears if I use the 2017 wikitext editor and show a preview.

In a rendered page, the same wikitext is shown like this:

Screenshot_2020-07-07 Editing ASCII - Wikipedia(1).png (195×486 px, 12 KB)

It's probably not important to invest a lot in detailed support for #categorytree in VE. For example, it's not very necessary to have an item that inserts it in VE's "Insert" menu. However, it should at least be correctly rendered while editing and previewing, and not shown as escaped HTML. It would also be nice to be able to change the parameters of an existing #categorytree instance, like mode and depth.

It is probably not so commonly used in English Wikipedia articles, but it is quite common in Russian Wikipedia articles and perhaps in other some other wikis.

Event Timeline

I suspect it is some missing CSS / resource module.

Arlolra triaged this task as Medium priority.
Arlolra moved this task from Needs Triage to Bugs & Crashers on the Parsoid board.
Arlolra subscribed.

Hmm, using the extension tag <categorytree>ASCII</categorytree> works fine, it's only the parser function that's an issue.

Ah, I see. The call to the parser function is returning html instead of wikitext, which is being sanitized. Hence the escaped anchor tags.

The extension probably needs to learn that it's doing preprocessing and just return an extension tag or something,
https://github.com/wikimedia/mediawiki-extensions-CategoryTree/blob/master/includes/CategoryTreeHooks.php#L115-L117

Change 676436 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/extensions/CategoryTree@master] Help Parsoid out by returning an ext tag when preprocessing

https://gerrit.wikimedia.org/r/676436

Change 676436 merged by jenkins-bot:

[mediawiki/extensions/CategoryTree@master] Return an extension tag when preprocessing a parser function

https://gerrit.wikimedia.org/r/676436

@arlorla Great to see a patch here. Thx! A few users had reported the problem on our side over the years. What is the timeline for prod? https://ru.wikipedia.org/api/rest_v1/page/html/%D0%9D%D0%B0%D0%BC%D0%B8%D0%B1%D0%B8%D1%8F#mwAdg seems to be still buggy.

That patch should ride this week's train.