Page MenuHomePhabricator

Add support for adding and outputting Z89/Html Fragments in WikifunctionsPFragmentHandler
Closed, ResolvedPublic

Description

We will ensure that Z89 HTML fragments are rendered as actual HTML in Wikipedia articles, ensuring seamless integration between Wikifunctions and Wikipedia.

Initial details derived from PRD

  • Make Z89s searchable and selectable in search in Visual Editor (not necessary if Z89 has a renderer to string)
  • Modify WikifunctionsPFragmentHandler and related logic to ensure Z89 types are handled correctly in Wikipedia articles in VisualEditor in read and edit mode. HTML tags should not be escaped and not displayed as plain text.
  • Collaborate with the Content Transform Team to verify that Parsoid can handle the HTML formatting and render it correctly.
  • Ensure that raw HTML rendering only applies to sanitized outputs.
  • Confirm that the output respects both performance and rendering expectations on Wikipedia pages.

Acceptance criteria

🔎 Search & Integration in VisualEditor

  • Functions with Z89-type as outputs can be searched and inserted using the VisualEditor function search.
  • The preview shows the raw HTML code. We do nothing for now with it.
  • Z89 shall (for this POC) not be used as an input field to a function.

🧩 Rendering in VisualEditor

  • Z89 function outputs are rendered as actual HTML, not escaped strings.
  • In edit mode, the user can see and modify the function call that outputs the Z89 content.
  • VisualEditor does not break layout or fail when Z89 output contains complex or invalid HTML

🚀 Performance & Compatibility

  • Rendering of Z89 content does not regress page performance

📄 Collaboration & Verification

  • Collaborate with the Content Transform Team to verify that: Parsoid supports and retains HTML formatting from Z89 outputs.

Tech specs

  1. WikifunctionsPFragmentHandler.php
    • Extend handling logic to detect Z89 outputs because we might want to use something else then newFromLiteral
    • Make sure to render a fragment that can render HTML
  1. Parsoid Integration
    • Investigate if we need Parsoid for rendering of HTML fragments received from Z89 evaluations.
  1. VisualEditor Function Integration
    • Update function search interface to allow functions with Z89 as return type to appear and be inserted.

🧪 Testing

  • Unit tests for any PHP changes
  • Manually test Edge cases: broken HTML, nested tags, long content, invalid content fallback.

Next quarter work

Some things we noted as out of scope for the POC but might be worth considering for the next iteration are listed below.

  • Z89 is not used yet in the POC as an input argument to functions in Visual Editor. This is nice for future work.
  • The Preview will show the html as a string not in a nice ace editor field. For the POC we do not touch this. But its nicer to have something better, especially for long html.

Event Timeline

Change #1155211 had a related patch set uploaded (by Daphne Smit; author: Daphne Smit):

[mediawiki/extensions/WikiLambda@master] Add VisualEditor support for Z89/Html Fragment type

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

DSmit-WMF changed the task status from Open to In Progress.Jun 10 2025, 2:24 PM
DSmit-WMF renamed this task from Add VisualEditor support for Z89/Html Fragment type to Add support for adding and outputting Z89/Html Fragments in WikifunctionsPFragmentHandler .Jun 11 2025, 12:18 PM

Change #1155211 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Add support for adding and outputting Z89/Html Fragments in WikifunctionsPFragmentHandler

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