Lars Gullik Bjønnes wrote:
> use of tex-mode with insets inside is a harder nut to crack...
> (especially if we speck of insets that can themselves have tex-mode
> inside)
Maybe I'm missing something, but why won't the following work?
While parsing, keep a stack (or piggyback on an existing stack)
corresponding to inset nesting levels, with an "are we in tex-mode" flag
per level. When pushing due to new inset, set the flag of the new level
to false. Upon "\latex latex" etc, change the flag in the current level
only.
I think that's how it used to work, at least in effect. If you think
about fonts and footnotes ("\emph{foo \footnote{bar} baz}") and similar
cases, they seem to have those semantics too.
Since tex-mode wasn't properly terminated, there must be lots of
documents out there with this problem.
Regards,
Eran