The wikitext (note the table ending with an open tr)
A {| ! B |- C
parses as
<p>A</p> <p>C</p> <table> <tbody><tr> <th>B</th> </tr> </tbody></table>
In the original example the table ended with |-}, C was some amount of text including headlines etc., the table appeared at the very end of the article.
One can't expect a perfect output for incorrect input, but at least the order should remain the same.
Version: 1.18.x
Severity: normal