Page MenuHomePhabricator

Add an additional class to the body tag showing Parsoid usage
Closed, ResolvedPublicFeature

Description

Feature summary (what you would like to be able to do and where):
Add an additional class to the body tag like rendered-with-parsoid to support JavaScript and CSS.

Benefits (why should this be implemented?):
This would be usefull for programmers. I think this would be the easiest way to detect Parsoid rendering both for CSS rules (body.rendered-with-parsoid) and JavaScript scripts.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

This is present in the ParserOutput extension data (core:parsoid-version and core:html-version) and it is the <body> tag reported by the REST API I believe and I could have sworn it was on the wrapper div for the content area as well, but I couldn't find it last time I looked.

Yes, we do already have this. Not a class but a data- attribute:

<div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr" data-mw-parsoid-version="0.22.0.0-alpha24" data-mw-html-version="2.8.0">

This could be targetted with CSS rules [data-mw-parsoid-version] ... but we'd actually recommend against doing that, since pages can (at present) often be composed of a combination of Parsoid and legacy content. Using CSS rules targetted to specific Parsoid typeof or other structures is more reliable in these mixed contexts.

The ParserMigration extension also adds a JsConfigVar named parsermigration-parsoid but that shouldn't be considered a stable API; the ParserMigration extension will go away once the Parsoid transition is complete.

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

[mediawiki/core@master] ParsoidParser: Export Parsoid HTML version as a JS config var

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

Change #1193499 merged by jenkins-bot:

[mediawiki/core@master] ParsoidParser: Export Parsoid HTML version as a JS config var

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

cscott added a project: Essential-Work.