I've become interested in this thanks to TemplateStyles. Currently, TemplateStyles scopes all styles to the `id="mw-content-text"` element to prevent styles from accidentally messing with site UI. I just now loaded a random page in VE and noticed that its content being edited is not within that element, so the template styles won't be applied in the editor. This isn't good.

At the same time, we have this bug complaining that the `id="mw-content-text"` element sometimes contains more than just the page output, for example it contains the diff tables, the edit form, category text, image metadata, and so on. The `mw-content-ltr` and `mw-content-rtl` classes mentioned here do slightly better, they don't hold the diff tables but do hold parts of category lists, the entire Flow page, and so on. And having to target multiple classes would bloat TemplateStyles's output.

It looks like the most straightforward option to getting just the parser output to be wrapped in some sort of container is to do just that: stick some code like this in near [[https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/parser/Parser.php;d038e889f72d17bbf03d2098111c928571c2c72d$592|this line in the Parser]]:
``` lang=php
        # Wrap non-interface ParserOutput in a class
        if ( !$this->mOptions->getInterfaceMessage() ) {
            $text = Html::rawElement( 'div', [ 'class' => 'mw-parser-output' ], $text );
        }
```
I don't know whether #VisualEditor and #Flow will get fixed up by that, though, or if they'll need some other work. I tried to set them up in mediawiki-vagrant, but neither actually functioned.


If we don't do that, we may be able to get by with a few more changes where ParserOutput is used.
* `OutputPage::addParserOutputText()`, either before or after the 'OutputPageBeforeHTML' hook call, will catch most cases.
** We'll probably need to copy the interface flag into the ParserOutput so that can only wrap the non-interface ParserOutputs.
* `EditPage::doPreviewParse()` needs to wrap its HTML too.
* Possibly the "Empty content container for LivePreview" in `EditPage::displayPreviewArea()` should have the class added.
* `TemplateSandbox::templateSandboxPreview()` where it basically duplicates `EditPage::getPreviewText()`
* `Translate::getDocumentationBox()` where it displays the qqq message
* Wherever in Flow that it generates the `flow-post-content` div.
* VisualEditor would probably need to add the class to its wrapper div, probably the same one that already has the 'mw-content-ltr' class.