On 09/25/2013 11:37 PM, Feng Yi wrote:
“long-term we are trying to
make template nesting more sane.”
for now, do you have a list that which templates should emit properly
nested output?
All of them should, but for some we'll have to be backwards-compatible
for a while.
Identifying unbalanced template-affected content is relatively easy. In
our DOM format, transclusion-affected content is marked as
mw:Transclusion and a data-mw attribute contains a 'parts' array of
involved transclusions and page wikitext. When there are unbalanced
templates involved, there will be more than one template in this array.
Typically the first and last template in this list will be wrapper-style
unbalanced templates. As template output can depend on the input, the
time and other varying data we'll have to do statistics for a robust
classification of templates.
See
https://www.mediawiki.org/wiki/Parsoid/Roadmap#Research_.2F_prototype:_Enfo…
for the roadmap on this. The idea we have been kicking around for a
while was to wrap unbalanced content in a <domparse> tag like this:
<domparse>
{{echo|unbalanced<table>}}
..
{{echo|</table>}}
</domparse>
This covers any content including transclusions and extensions, and can
be implemented as a tag extension in the PHP parser. Content inside it
will be parsed to a balanced DOM fragment.
This is easy to apply manually from now on, but we'll have to find a
good solution that also works for old revisions. HTML diffing against
those should work as expected.
Gabriel