If you add a formula (or other inline item) to a normal paragraph, everything works in VE consistently with MW (yay).
If you add a formula (or other inline item) to a pre-formatted paragraph, everything still works works (yay).
If you add a gallery (or other block item) to a normal paragraph, everything works in VE consistently with MW (yay).
If you add a gallery (or other block item) to a pre-formatted paragraph, VE tries to let you do that, and MW decides retroactively that the paragraph wasn't actually pre-formatted (boo), unless it's a <pre>-formatted rather than indent-pre-formatted block, in which case galleries don't work.
Not tested with Headings, but there's probably similar wonkiness there too.
*sighs*
Version: unspecified
Severity: normal