(This bug notes issues with both Parsoid and VisualEditor. I think all of this is caused by the terrible mistake that is bug 529 / bug 12974. I'll leave it for you to figure out this mess. :) )

----

On mediawiki.org, there is a family on fancy templates like [[mw:Template:MW 1.23]] that generate a right-floated MediaWiki version number in a frame.

These templates generate a wikitext table (starting with '{|'), which means that due to bug 529 / bug 12974 a newline is prepended before it. This behavior is incredibly annoying in practice, but it seems that we're very much wedded to it because it made Parsoid people's lives easier.

----

However, Parsoid rendering of this particular template is inconsistent with PHP. On [[mw:Manual:Skinning#Localisation_messages]], PHP generates an empty paragraph before the table, while Parsoid doesn't and produces an about-grouped pair of <span>\n</span><table>…</table> (the span tag only contains the prepended newline).

This rendering, that looks good in Parsoid/VisualEditor, therefore looks like crap in PHP parser.

Note that the <span> is not nested in a <p> or any other block-level element, it just sits there right in the <body>. (It is not visible since, as I mentioned, it just contains some whitespace.)

----

More problems appear when you try to edit text with this template in VisualEditor.

For example, testing on [[mw:Manual:Skinning#Localisation_messages]]:

* Place cursor before/after one of the templates.
* Press 'Right'/'Left' keyboard key twice.
** First press selects the template, as expected.
** Second press scrolls the page all the way up.

* Try inserting the "MW 1.23" template on an empty line.
** Observe that the blue highlights are different than for the
   templates already present on the page – there is both the table, as
   well as a single "space" (?) in text flow. Observe that the context
   menu is placed weirdly in the middle of the page.
** Place cursor after the "space" and try typing. Weird things happen,
   sometimes I get an exception "Uncaught Error: Unbalanced set of
   replace operations found", sometimes my input is duplicated or I
   get snowmen and pawns.
** Try deleting the template in any way. It is deleted, but the page
   is scrolled all the way up.

* Edit the two paragraphs right after the "Localisation messages"
  heading (add a letter somewhere in the middle or something).
* Try saving the page.
** Observe that multiple newline-related changes appear to have been
   made. Strangely, there are actually no changes, but the *before*
   half of the comparison has some newlines removed.

--------------------------
**Version**: unspecified
**Severity**: major