On 10.08.2011 01:55, Erik Rose wrote:
Though, as we learned the hard way, one should not assume that rendering a template separately yields the same result as substituting its source text into the caller and then rendering the whole thing at once. For example, we wanted to allow templates on support.mozilla.com to contain just single bullet points...
- Hello there
...for inclusion into lists in the caller. MW supports this. The naive approach of rendering the template on its own leaves you with an extra list (and possibly invalid markup—I forget). Our new parser (https://github.com/erikrose/mediawiki-parser) subs the parametrized template into the caller and then renders once.
This is one of the most important and hotly debated questions abotu the new parser design: should it allow syntactically incomplete templates, or not?
If we allow this, we are basically stuck with representing text using one specific syntax internally, and we can not parse a page without resolving all templates. All we can do up front is a preprocessor pass (as we already do).
If we do not allow this, we can convert wikitext to wikidom independantly of the content of that database, that is, there is a stable mapping from syntax to dom. This would allow us to use the dom as the internal representation, and allow people to use whatever syntax they want, as long as we have a clean round trip for that syntax. it would also make it very easy to write generators for various kinds of output, like tex or pdf.
However, requiring syntactically complete templates would require a pretty heavy transition for existing content. Is it worth it? I think in the long run, yes.
-- daniel