Page MenuHomePhabricator

Category template separated from comment on zh.wiki
Closed, ResolvedPublic

Description

Seen quite a few diffs like this: https://zh.wikipedia.org/?diff=62989766

Looks like the reply tool probably shouldn't be separating these templates from their comments.

Test instructions

  • Write a top level comment, followed by a category, or template that includes a category, e.g. Comment. ~~~~ [[Category:Test]]
  • Reply to that comment with the reply button

Observed
The category moves to the end of the page: https://meta.wikimedia.org/w/index.php?title=User_talk%3AESanders_%28WMF%29%2Fsandbox&type=revision&diff=20767250&oldid=20767248

Expected
The category doesn't move and the reply goes beneath the original comment.

Event Timeline

Foo {{category template}} becomes <p>Foo</p><p><meta....></p> but in a comment :Foo {{category template}} puts the <meta> tag inside the list item as expected?

Apparently this is a very specific bug, where a category template is added *after a signature* in the *first comment in a thread* (the one not inside a list item), and in that case the category gets moved down.

Foo ~~~~ [[Category:Book]]
: Bar ~~~~ [[Category:Book]]

->

<p>Foo ~~~~ </p>
<link rel="mw:PageProp/Category" href="./Category:Book">
<dl>
    <dd>Bar ~~~~
        <link rel="mw:PageProp/Category" href="./Category:Book">
    </dd>
</dl>

Note the category gets hoisted out of the <p> but not the <dd>. I think we saw something similar to this before. It would be nice if Parsoid was consistent and kept the category in the paragraph. The category is in the paragraph if there is text after it.

In Parsoid this is WTUtils::isRenderingTransparentNode(), which seems to include:

  • HTML comments
  • "SOL-transparent links": <link> tags with rel attributes matching /(?:^|\s)mw:PageProp\/(?:Category|redirect|Language)(?=$|\s)/
  • <meta> tags which don't have `typeof="mw:StartTag" or "mw:EndTag" (these are orphaned literal HTML tags; they might be stripped before Parsoid emits its final HTML)
  • Fallback ID spans: <span typeof="mw:FallbackId"> (found inside headings, you can probably ignore these)

Skipping HTML comments, <meta>, and <link> tags should be good enough, I think.

For context:

Change 645576 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/DiscussionTools@master] Handle category links like comments (rendering-transparent nodes)

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

Change 645576 merged by jenkins-bot:
[mediawiki/extensions/DiscussionTools@master] Handle category links like comments (rendering-transparent nodes)

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

A particularly complex case we should add to the integration tests:

https://en.wikipedia.org/?diff=993157834

A closing div, followed by a comment, empty tracking template and category

Change 647219 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/DiscussionTools@master] Skip over empty inline nodes (e.g. tracking templates)

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

Change 647219 merged by jenkins-bot:
[mediawiki/extensions/DiscussionTools@master] Skip over empty inline templates (e.g. tracking templates)

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

Working as expected it seems. On the diff view, the reply is now being placed right beneath the first comment that includes the category template.

The diff view:

Screen Shot 2020-12-16 at 12.35.16 PM.png (1×1 px, 276 KB)

The page:
Screen Shot 2020-12-16 at 12.28.22 PM.png (436×1 px, 100 KB)

Stang moved this task from Backlog to Closed on the Chinese-Sites board.
Stang unsubscribed.