One other quick comment

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> LaTeX fragments should not break paragraphs, or tables. So you need to
> prevent inserting blank lines, or even newlines characters in the case
> of tables.

I don’t think we need to worry about newlines, particularly as this only applies
to elements which are not defined by a \begin{env} \end{env} block, ruling
tables out :P

Another query from me, with something like a blank line, why is a user-error
raised? Surely just strip blank lines from the buffer? I can’t think of any
situation where this would be undesirable.