Why & What
Each piece of content has a number of styles/stylesheets that it needs to display.
Such stylesheets are determined by MediaWiki depending on many factors (extensions installed and content in page, among other things) and may vary depending on which page you are rendering.
API consumers need to know which styles are required for a page, and where to fetch them from, in order to properly style the content of the page if they choose to apply them.
How
Currently
This styles are currently referenced in the parsoid HTML with a link tag:
<link rel="stylesheet" href="//en.wikipedia.org/w/load.php?modules=mediawiki.legacy.commonPrint%2Cshared%7Cmediawiki.skinning.content.parsoid%7Cmediawiki.skinning.interface%7Cskins.vector.styles%7Csite.styles%7Cext.cite.style%7Cmediawiki.page.gallery.styles&only=styles&skin=vector">
Example from https://en.wikipedia.org/api/rest_v1/page/html/Banana
As structured data, this would be something like:
interface Styles { url: string, modules: string[] }
In this specific example:
{ url: '//en.wikipedia.org/w/load.php?modules=' modules: [ "mediawiki.legacy.commonPrint,shared", "mediawiki.skinning.content.parsoid", "mediawiki.skinning.interface", "skins.vector.styles", "site.styles", "ext.cite.style", "mediawiki.page.gallery.styles" ] }
In apps, there is a subset of all the styles that get fetched at compile time and bundled with the application, and manually applied to the content.
- There may be cases where articles have styles missing with this approach
In mobile web styles are gathered by mediawiki & ResourceLoader, and output into the page. This approach wouldn't work with mobile web as an API driven skin, consuming parsoid content.
Questions
Should this be exposed in PCS or MCS or at all?
...
If it should, should it be served as JSON metadata of the content or as HTML tags like it is on the parsoid HTML?
...
Add other questions and discussed answers above
See also
- T105845: RFC: Page components / content widgets: Discusses need for exposing content-specific modules, along with other metadata.