Create a solution to automatically corrects template and inline styles that do not comply with night mode standards. This includes identifying styles that specify a background color without a corresponding text color and applying a suitable text color. The task involves algorithm development, testing across different articles and templates, and implementing a safe deployment strategy to minimize disruption.
There again a number of different paths:
- If you use the ParserOutputPostCacheTransform hook you will get output from both Parsoid and the legacy parser, and because this is post-cache it won't affect the HTML served to VisualEditor, etc and so you're not likely to corrupt other downstream clients. But because this is post-cache, whatever transformation you write should be as efficient as possible. (There are still edge caches in front of this, so it's not after *all* caching, but its still fairly performance-sensitive.)
- A variation of this just adds a class marker to any tag which defines a style attribute, in order to make a client-side [style*="color"] { ... } stylesheet more efficient, eg: .mw-defines-style[style*="color"] { ... }
- Modifying TemplateStyles is technically the cleanest, but of course only affects TemplateStyles
- In an ideal world, Sanitizer::checkCSS in core would use the same css-sanitizer library that TemplateStyles does, which would make any CSS mutation more technically clean, but this is probably a heavier lift than we'd like to tackle right now, especially since we'd have to consider the comparative performance of css-sanitizer versus the regexp that core uses.