The <p><br></p> that was fostered here hints at newlines in the template expansion, which then trigger the p/br insertion. Those might not be correct, as the PHP parser + tidy does not seem to emit them. I'll have a look.
This was indeed not correct. Unbalanced table tags threw our 'in table' state tracking on the token stream off. Reported in https://bugzilla.wikimedia.org/show_bug.cgi?id=53287, and should be fixed by https://gerrit.wikimedia.org/r/#/c/80681/.
Gabriel