Fix for issue #26

The problem was that switching math_mode is fragile because it checks for
having a line entirely of the form

\end{equation}

This is always correct for the LaTeX coming from the Stacks project,
but since we've been changing the lines earlier in convertLaTeX
function it may no longer be true...

So there may be more cases of this problem where line endings get removed...
(for example in the replacement of begin{proof})