Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Page MenuHomePhabricator

Parsoid should render empty references list the same as default parser
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What should have happened instead?:
In Russian Wikipedia we want to simplify the maintenance of disambiguation pages by providing an automatic <references /> section anywhere there are <ref> tags on a page or through transclusions. See discussion and context at https://ru.wikipedia.org/wiki/Википедия:Форум/Предложения#Автоматизация_раздела_примечаний_на_страницах_значений

I’ve recently made this happen for all pages with disambiguation template but it was reported me in the link above that Parsoid / mobile apps generate a different code markup. This markup prevents the template from being rendered correctly. I do not see why it is generated the way it is generated, empty elements like that are entirely unneeded and because of this, there is no way to do what we want to do in Parsoid page views correctly.

In other instances it produces double lists:

It would be great if an empty <references /> tag didn’t display any code or displayed as minimal code as possible.

Event Timeline

Restricted Application added subscribers: Base, Aklapper. · View Herald Transcript

Shouldn't be too hard to fix -- we just need to update the post-processing in the Cite extension code to remove empty wrappers.

Looks like this CSS rule doesn't apply in Parsoid because of the empty refs lists: .mw-parser-output .ts-Неоднозначность-reflist > [role="heading"]:only-child

Note that we can only safely delete this HTML for empty ref lists when they come from templates OR are auto-generated. Otherwise, on VE edits in proximity of the references, Parsoid will remove the "<references />" tag. An alternative is to process canonical HTML for read views which doesn't impact VE, but we want to avoid extra processing on the read views path if possible.

We'll chat about this and see what makes sense. But, if you have any additional thoughts, let us know.

Change #1031425 had a related patch set uploaded (by Subramanya Sastry; author: Subramanya Sastry):

[mediawiki/extensions/Cite@master] WIP: For zero <ref>s, strip <references> html in some cases

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

Would something like this work for you,

<html>
<head>
<style>
    .one {
        display: inline-flex;
        flex-direction: column-reverse;
    }
    .three:empty ~ .two {
        display: none;
    }
</style>
</head>
<body>
<div class="one">
    <ol class="three"></ol>
    <div class="two">
        123
    </div>
</div>
</body>
</head>

We'd have to suppress the mw-references-wrap for the ol to be a sibling but that seems fine for an empty list (or add a class to the div to say the list is empty).

Another idea could be to make outputting a heading with the references list an option, like <references heading="Примечания" /> that would produce the desired output.

The markup you are proposing with flexbox is inaccessible. The heading="" option seems too fragile because the syntax required can be pretty different. I don’t see why Parsoid can’t simply output the same markup that is already outputted in the regular parser.

I don’t see why Parsoid can’t simply output the same markup that is already outputted in the regular parser.

That was explained in T364830#9793969. Parsoid has different requirements than the legacy parser. Its output needs to be able to be serialized back into the wikitext it used to generate it. One of the strategies it employs is leaving behind an empty list to know that a references tag was present there in the source.

The markup you are proposing with flexbox is inaccessible. The heading="" option seems too fragile because the syntax required can be pretty different.

Ok, good points. I'm just trying to explore solutions before concluding the one proposed in T364830#9794009 is our best option. The inconsistency of only dropping the empty list in templates may help here but could be undesirable elsewhere.

For example, if an editor inserts a reference on a page where none existed before, they may conclude they need to also insert a references list. However, a references list may have already existed on the page, it was just suppressed because it was empty. An invisible cue to the editing client is useful in this case.

It looks like :only-child only considers elements. So, maybe leaving a comment as a marker could work, <!-- mw-empty-references-list --> or some such.

An alternative is to process canonical HTML for read views which doesn't impact VE, but we want to avoid extra processing on the read views path if possible.

Maybe that's the better option.

Can you clarify what is needed from me to bring this task forward? I think the comment solution you are proposing is the better one out of the proposed options, if Parsoid would be helped by having a comment, then I see nothing wrong with that.

While a comment as a marker could work, it might not be the most straightforward to implement.

We discussed this as a team and @cscott writes,

Per tech forum discussion, current preference is to add a <references heading="some heading text"> feature to Cite, which would include the heading at the top of the generated reference list (and/or suppress it if no references are present; and/or add a TOC entry for the references list).

I will try to prototype that but can you say a bit more about what you mean by,

The heading="" option seems too fragile because the syntax required can be pretty different.

I will try to prototype that but can you say a bit more about what you mean by,

Forgot to reply: mostly I mean that, although in my current case I did role="heading" aria-level="2", in a hypothetical scenario where this attribute becomes a thing, people might need different levels of headings (<h2>/<h3>/<hN>). So that needs to be properly represented in a hypothetical attribute as well.