Introduce the notion of DOM scopes in wikitext (https://www.mediawiki.org/wiki/User:SSastry_%28WMF%29/Notes/Wikitext#DOM_scopes). The idea is that when enforced, HTML produced by the wikitext construct will be balanced in isolation.
The first and easiest application of this would be for top level sections (T114072) where we can experiment and prototype this idea (without expliciting calling it such). We would have to understand the implications for editing, and for the parsing implementations (ease of supporting this and performance impacts). This can inform the other contexts where this can be extended to.In the longer run, this can be applied to template output, extension output, tables, image captions -- as part of the gradual move towards evolving wikitext towards a newer Wikitext 2.0 (T112996).
Doing this can help with:
- editability: individual dom scopes can be edited independently and in isolation. This can help VE as well as other wikitext editing tools.
- performance:you can parse and process DOM scopes somewhat in isolation -- a step towards supporting incremental parsing
- ability to reason about the markup: you don't have to look at rest of the page to make sense of what this piece of code does (I am deliberately exaggerating this to highlight that when enforced, this property is not dependent on ability to not have wikitext markup errors).
The name and notion is up for discussion, but the idea is to come up with an understandable and enforceable concept that can be applied consistently.