Page MenuHomePhabricator

Parsoid should mark itself up in a way that CSS/JavaScript can target it
Open, Needs TriagePublicFeature

Description

Feature summary (what you would like to be able to do and where):
JavaScript and CSS code should be able to reliably detect when Parsoid HTML is being used and what version is being used so it can adapt accordingly to signficant breaking changes while still being backwards compatible. The solution should meet the following criteria:

  • Should be possible to target styles at Parsoid HTML or legacy parser HTML via a single CSS selector e.g. [data-parsoid] a
  • Should be possible to target styles at a specific version of Parsoid
  • Should be possible to check whether Parsoid HTML is being returned in JavaScript
  • Should be possible to get Parsoid version by reading HTML in JavaScript

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):

  • Handling breaking changes to the HTML
  • Migrating section collapsing code on MobileFrontend

Benefits (why should this be implemented?):

  • Easier to roll back changes safely when issues occur
  • Easier to prepare for changes prior to issues occurring.

Event Timeline

FWIW JS code can figure out if parsoid is being used to render the page by looking for parsermigration-parsoid in the JsConfigVars, but that's a temporary thing put there by the ParserMigration extension, not a "real" solution.

Change #1023950 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] [OutputTransform] Add data-mw-parsoid-version to wrapper div

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

Change #1023950 merged by jenkins-bot:

[mediawiki/core@master] [OutputTransform] Add data-mw-parsoid-version to wrapper div

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