Add error when readBalanced fails to balance at end of Mouth#872
Conversation
|
To reproduce the error in the master latexml from the command-line, here is a one-liner: I would clearly expect this to throw an error, such as the one from this PR |
|
Thanks; Actually, I have a nagging doubt that there was a reason to leave w/o error, but can't remember why; perhaps the usually-expected error that follows is a clearer one? Anyway, merge and see what happens :> |
|
I was investigating the potential reasons, and the most pertinent bit of logic was the fact some Mouths We'll be informed upon the next arXiv rerun :> |
|
I may have found out why it was there. I am now getting a rather unpleasant error when loading elsarticle.cls, on a vanilla empty-ish input: Hm, need a way to keep the error for the good cases, but kick it out of here. |
|
Basically it's the technique used internally by RawTeX, I'm amazed we don't have any tests that use that and would fail? $stomach->getGullet->readingFromMouth(LaTeXML::Core::Mouth->new($text), sub { |
|
Well, while I have connected the error to the piece of code using a new Mouth, I haven't yet connected to the exact reason |
|
Exact RawTeX line with this error is: RawTeX('\newenvironment{pf}{\begin{@proof}[\proofname]}{\end{@proof}'); |
|
One-liner to reproduce: |
|
Oh my. After staring here for an unreasonable amount of time... Is there a typo in the RawTeX string? I printed a whole lot of Dumper messages and it now looks as if the ending: should have an additional ending brace: Does this make sense? I can commit that right away. |
|
I have verified this is the issue, will push directly to master (since we're talking 1 character) |
|
Done: a090611 Hope you don't mind my first commit to master @brucemiller ! I think this PR may catch some interesting RawTeX oversights now, more convinced it was correct to add this error message. |
|
bravo & welcome ! :> |
This was a bit of a shocker in Authorea editing. There were obvious pieces of wrong LaTeX content that never returned an error from latexml, such as:
Importantly, this is being converted in fragment mode, and has no
\end{document}in the same mouth to throw a grouping error. This revealed a particular case of unreported errors in LaTeXML:When a Gullet->readBalanced call does not have a closing brace, the read silently succeeds to slurp all content until the end of the Mouth
This can cause some serious issues if the error is committed early in a large chunk of latex, naturally. So I suggest throwing an informative error, and then proceeding as usual. It is good enough for users to correct their mistake in online editing. Example interface from Authorea:

Feedback welcome on how exactly to structure the error.