Page MenuHomePhabricator

Text on same line as template making a header causes non-matching Parsoid output
Closed, DeclinedPublic


I have a template {{X}} that generates a section header, say ==a==. I write a{{X}} all on one line. The PHP parser generates the paragraph a==a==, but the Parsoid HTML endpoints give me a paragraph a followed by a header element. I would expect the Parsoid HTML to also consist only of the paragraph a==a==.

Event Timeline

This is broadly related to T14974: The newline added to a template, magic word, variable, or parser function that returns line-start wikicode formatting (*#:; {|) causes unexpected parsing. Specifically, see T14974#3223831 - that specific feature when made available will provide a bit more control about context but that will apply to all uses of that template (unlike in this scenario, where a{{X}} and {{X}} will generate a heading or not depending on context of the line on which it was used).

Additional clarification since I didn't explicitly clarify this above.

Parsoid currently parses all templates as if they always started on a newline. So, {{X}} will always generate a heading no matter whether it is used as a{{X}} or {{X}}.

When balanced templates feature is supported, the options for start-of-line context for a template will expand beyond the single option ("always starts on a newline") currently, but as mentioned above, that will be applied consistently to all uses.