Page MenuHomePhabricator

Save edited main reference content back to inline main+details
Closed, ResolvedPublic

Description

User story:

As VE user I want to be able to correctly see and save sub-refs when main and details content are part of one reference tag.

Background:

This task is about wiring the edited main ref back into a main+details ref where it came from. Currently, editing a main ref (adding text "NEW") will save it in list-defined references:

image.png (239×1 px, 29 KB)

Acceptance criteria:

Assume Wikitext like:

<ref name="main-ref" details="p. 123">Old main text</ref>

After editing either the main or the details content it should result in Wikitext like

<ref name="main-ref" details="p. 123">New main text</ref>

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Change #1130979 had a related patch set uploaded (by Awight; author: Awight):

[mediawiki/extensions/Cite@master] [WIP] Exploring why wrong main content is used

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

Change #1131261 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/Cite@master] Fix id of the main body element

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

I'll move this back for now but here some things I found:

  • refs will only be processed in the conversion to Wikitext when they have been touched. So when you edit the main in VE but not the sub then the later will not be processed by Parsoid it seems.
  • In RefTagHandler::domToWikitext() the doc you get from $extApi->getTopLevelDoc() does not include the whole doc in the body. But you will find all the data you need in the DataBag that can be retrieved with DOMDataUtils::getBag(doc)
awight renamed this task from Save edited, inline main reference content back to main+details to Save edited main reference content back to main+details.Apr 2 2025, 9:40 AM
awight updated the task description. (Show Details)

The following document can be safely edited in VE, both the subref and main ref:

<ref name="book">The book</ref>
<ref details="p. 123" name="book" />

It's possible that this task was actually caused by issues with T387847: Parsoid handles subref coming before its main ref, I'm merging as a duplicate.

The following document can be safely edited in VE, both the subref and main ref:

<ref name="book">The book</ref>
<ref details="p. 123" name="book" />

It's possible that this task was actually caused by issues with T387847: Parsoid handles subref coming before its main ref, I'm merging as a duplicate.

It's not working for wikitext like

<ref name="main-ref" details="p. 123">Old main text</ref>

There I get

<ref name="main-ref" details="p. 123">Old main text</ref>
<references>
<ref name="main-ref">New main text</ref></references>

After saving.

Change #1131261 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Fix id of the main body element

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

WMDE-Fisch renamed this task from Save edited main reference content back to main+details to Save edited main reference content back to inline main+details.Apr 7 2025, 1:02 PM
WMDE-Fisch edited projects, added Story; removed Patch-For-Review.
WMDE-Fisch updated the task description. (Show Details)

Some breadcrumbs:

  • List-defined reference would be omitted when the VE dm2dom serializer sees a ref with isMainWithDetails, which makes the output more correct but breaks the symmetry between reading and saving Parsoid HTML. Merging the two refs should be left to Parsoid.
  • Unknown why the old footnote body is leaking through, but it seems to be the contents of the element located by searching for HTML ID mainBody.

Breadcrumbs:

  • ve.dm.MWReferencesListNode.static.toDomElements is checking originalDomElementsHash and since this is set, it pulls the reflist from stored original html. This accounts for the old text being present.
  • We don't know why but even in non-subref use cases, the HTML output by VE and sent to Parsoid includes an old version of the reflist, even if changes were made. My guess is that it was to save effort on re-rendering the reflist. Updates to the footnote body are sent in ref data-mw. If the reflist is wrong, maybe we should be sending it empty other than list-defined refs?
  • When Parsoid html2wt reads the reflist data-mw ref, it has access to isMainWithDetails but fails to glue back to the details.

Theory:

  • main ref content could be pulled from the reflist data-mw, rather than from the full document.

Looking through the reflist data-mw is probably too expensive—footnote text and ref identity are kept in data-mw within the data-mw, so the only practical way to use the data would be to iterate over it once and cache.

Next step:

  • VE should update reflist contents so that the new footnote texts can be easily searched by ID.

Change #1142590 had a related patch set uploaded (by Awight; author: Awight):

[mediawiki/extensions/Cite@master] [WIP] Send Parsoid HTML with updated reflist content

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

Change #1140157 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Cite@master] Rename slightly confusing "isMain…WithDetails" attributes

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

Change #1144571 had a related patch set uploaded (by Awight; author: Awight):

[mediawiki/extensions/Cite@master] [WIP] Test for changing main part of main+details

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

Change #1144571 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Converter tests for main+details

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

awight moved this task from Doing to Watching / Stalled on the WMDE-TechWish-Sprint-2025-05-14 board.

Still not solved, but we can deprioritize for the current sprint.

Change #1140157 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Rename slightly confusing "isMain…WithDetails" attributes

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

Change #1148878 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Cite@master] Fix incompletely renamed attributes in test cases

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

Change #1148878 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Fix incompletely renamed attributes in test cases

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

Change #1168025 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/Cite@master] Parsoid: Ignore synthetic main refs from details

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

Change #1130979 abandoned by WMDE-Fisch:

[mediawiki/extensions/Cite@master] [WIP] Exploring why wrong main content is used

Reason:

Will be solved with https://phabricator.wikimedia.org/T396017

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

Change #1142590 abandoned by WMDE-Fisch:

[mediawiki/extensions/Cite@master] [WIP] Send Parsoid HTML with updated reflist content

Reason:

See work in https://phabricator.wikimedia.org/T396017

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

Change #1168025 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Parsoid: Ignore synthetic main refs from details

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

Change #1169685 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Adding a html2wt test for synthetic list defined refs

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

Change #1173884 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/Cite@master] Adding Converter and fitting Parsoid tests for details

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

Change #1173884 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Converter: Improve simple main+details and add fitting Parsoid tests

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