New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

babel.def throws an error #957

Closed
swalter62 opened this Issue Mar 1, 2018 · 15 comments

Comments

Projects
None yet
3 participants
@swalter62

swalter62 commented Mar 1, 2018

Hi Bruce,
Version 0.8.2 works great for me with one minor error-generating flaw, which breaks my scripts, unfortunately. The texlive babel package (2017.20180110-1), with either the english or french option, induces an \ifcase incompletion.
Here's the MWE:

\documentclass{article}
\usepackage[english]{babel}
\begin{document}
This is a test.
\end{document}

And here's the latexml output:

walter@mba:/home/pub/test$ latexml babel-mwe.tex
latexml (LaTeXML version 0.8.2; revision 35ba0794)
processing started Thu Mar  1 17:21:48 2018

(Digesting TeX babel-mwe...
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/TeX.pool.ltxml...
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/eTeX.pool.ltxml... 0.01 sec)
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/pdfTeX.pool.ltxml... 0.00 sec) 0.12 sec)
(Processing content /home/pub/test/babel-mwe.tex...
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/LaTeX.pool.ltxml... 0.12 sec)
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/article.cls.ltxml... 0.01 sec)
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/babel.sty.ltxml...
(Processing definitions /usr/share/texlive/texmf-dist/tex/generic/babel/babel.sty...
(Processing definitions /usr/share/texlive/texmf-dist/tex/generic/babel/switch.def... 0.05 sec)
(Processing definitions /usr/share/texlive/texmf-dist/tex/generic/babel-english/english.ldf...
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/babel.def.ltxml...
(Processing definitions /usr/share/texlive/texmf-dist/tex/generic/babel/babel.def...
(Processing definitions /usr/share/texlive/texmf-dist/tex/generic/config/language.def... 0.02 sec)
(Processing definitions /usr/share/texlive/texmf-dist/tex/generic/babel/txtbabel.def... 0.00 sec) 0.54 sec) 0.55 sec) 0.75 sec) 1.19 sec) 1.64 sec) 1.83 sec)
Error:expected:\fi Input ended while conditional \ifcase was incomplete
	at Anonymous String; line 1 col 0
	started at at /usr/share/texlive/texmf-dist/tex/generic/babel/babel.def; line 1260 col 7
 1.97 sec)
(Building...
(Loading compiled schema /usr/local/share/perl/5.26.1/LaTeXML/resources/RelaxNG/LaTeXML.model... 0.01 sec). 0.05 sec)
(Rewriting... 0.00 sec)
(Finalizing... 0.00 sec)
Conversion complete: 1 error.
processing finished Thu Mar  1 17:21:50 2018
<?xml version="1.0" encoding="UTF-8"?>
<?latexml searchpaths="/home/pub/test"?>
<?latexml class="article"?>
<?latexml package="babel" options="english"?>
<?latexml RelaxNGSchema="LaTeXML"?>
<document xmlns="http://dlmf.nist.gov/LaTeXML">
  <resource src="LaTeXML.css" type="text/css"/>
  <resource src="ltx-article.css" type="text/css"/>
  <para xml:id="p1">
    <p>This is a test.</p>
  </para>
</document>

As you can see, the latexml output is fine; the only problem that I can see is that latexml throws an error on the incomplete \ifcase in babel.def. Do you see what's going on?
Best,
Scott

@dginev

This comment has been minimized.

Collaborator

dginev commented Mar 1, 2018

Hi Scott,

Could you attach your exact babel.def file to the issue? You may need to archive it, or just paste it verbatim in a comment. Obtaining that specific file at its specific version is a bit of a hassle.

Thanks for the report!

@swalter62

This comment has been minimized.

swalter62 commented Mar 1, 2018

Hi Deyan,
Here's my babel.def:

https://gist.github.com/dginev/e87b32ccdfa2e5e6cceeda38ec480e0f

This could well be a texlive issue, but I only noticed the error after an update of LaTeXML.
Thanks for your help!
best,
Scott

@dginev

This comment has been minimized.

Collaborator

dginev commented Mar 1, 2018

Hi Scott,

Thank you for the file, I have moved it to a gist to keep the discussion thread readable. Will take a look.

@dginev dginev added this to the LaTeXML-0.8.3 milestone Mar 29, 2018

@dginev dginev self-assigned this Apr 16, 2018

@dginev

This comment has been minimized.

Collaborator

dginev commented Apr 16, 2018

Hi @swalter62 , the latest master now processes the babel.def correctly from what I can see, the issue seems to have been resolved by the latest updates.

Could you take a look if the latest master works for you just to be sure?

@swalter62

This comment has been minimized.

swalter62 commented Apr 16, 2018

Hi Deyan,
I downloaded the latest master, but am getting the same error as before. I wonder if this is a texlive issue? I have version 2017.20180305-1 installed. Here is the output:

latexml (LaTeXML version 0.8.2; revision 4dbf7550)
processing started Mon Apr 16 22:44:35 2018

(Digesting TeX babel-mwe...
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/TeX.pool.ltxml...
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/eTeX.pool.ltxml... 0.01 sec)
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/pdfTeX.pool.ltxml... 0.00 sec) 0.12 sec)
(Processing content /home/pub/test/babel-mwe.tex...
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/LaTeX.pool.ltxml... 0.13 sec)
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/article.cls.ltxml... 0.01 sec)
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/babel.sty.ltxml...
(Processing definitions /usr/share/texlive/texmf-dist/tex/generic/babel/babel.sty...
(Processing definitions /usr/share/texlive/texmf-dist/tex/generic/babel/switch.def... 0.05 sec)
(Processing definitions /usr/share/texlive/texmf-dist/tex/generic/babel-english/english.ldf...
(Loading /usr/local/share/perl/5.26.1/LaTeXML/Package/babel.def.ltxml...
(Processing definitions /usr/share/texlive/texmf-dist/tex/generic/babel/babel.def...
(Processing definitions /usr/share/texlive/texmf-dist/tex/generic/config/language.def... 0.02 sec)
(Processing definitions /usr/share/texlive/texmf-dist/tex/generic/babel/txtbabel.def... 0.00 sec) 0.48 sec) 0.49 sec) 0.69 sec) 1.11 sec) 1.58 sec) 1.78 sec)
Error:expected:\fi Input ended while conditional \ifcase was incomplete
	at Anonymous String; line 1 col 0
	started at at /usr/share/texlive/texmf-dist/tex/generic/babel/babel.def; line 1295 col 7
 1.92 sec)
(Building...
(Loading compiled schema /usr/local/share/perl/5.26.1/LaTeXML/resources/RelaxNG/LaTeXML.model... 0.01 sec). 0.05 sec)
(Rewriting... 0.00 sec)
(Finalizing... 0.00 sec)
Conversion complete: 1 error.
processing finished Mon Apr 16 22:44:37 2018
<?xml version="1.0" encoding="UTF-8"?>
<?latexml searchpaths="/home/pub/test"?>
<?latexml class="article"?>
<?latexml package="babel" options="english"?>
<?latexml RelaxNGSchema="LaTeXML"?>
<document xmlns="http://dlmf.nist.gov/LaTeXML">
  <resource src="LaTeXML.css" type="text/css"/>
  <resource src="ltx-article.css" type="text/css"/>
  <para xml:id="p1">
    <p>This is a test.</p>
  </para>
</document>

If there's anything I can do to assist, let me know.

Best,
Scott

@dginev

This comment has been minimized.

Collaborator

dginev commented Apr 17, 2018

Sorry to waste your time, it's just that the babel.def example you provided seemed to work well for me when I also provided a txtbabel.def file.

It's tricky to diagnose when I can't reproduce, but I will try to update my texlive and test again.

@swalter62

This comment has been minimized.

swalter62 commented Apr 17, 2018

I neglected to mention that that the installation test battery fails on babel, but I figured you knew this already. Here's the relevant output, for easy reference:

t/80_complex.t ......... ok   
t/81_babel.t ........... 1/6 
Error:expected:\fi Input ended while conditional \ifcase was incomplete
	at Anonymous String; line 1 col 0
	started at at /usr/share/texlive/texmf-dist/tex/generic/babel/babel.def; line 1295 col 7
t/81_babel.t ........... 2/6 
Error:expected:\fi Input ended while conditional \ifcase was incomplete
	at Anonymous String; line 1 col 0
	started at at /usr/share/texlive/texmf-dist/tex/generic/babel/babel.def; line 1295 col 7
t/81_babel.t ........... 3/6 
Error:expected:\fi Input ended while conditional \ifcase was incomplete
	at Anonymous String; line 1 col 0
	started at at /usr/share/texlive/texmf-dist/tex/generic/babel/babel.def; line 1295 col 7
t/81_babel.t ........... 5/6 
Error:expected:\fi Input ended while conditional \ifcase was incomplete
	at Anonymous String; line 1 col 0
	started at at /usr/share/texlive/texmf-dist/tex/generic/babel/babel.def; line 1295 col 7
t/81_babel.t ........... ok   
t/82_moderncv.t ........ ok   
t/90_latexmlpost.t ..... ok   
t/91_latexmlc_api.t .... ok   
t/92_profiles.t ........ ok     
t/931_epub.t ........... ok   
t/93_formats.t ......... ok     
t/94_runtimes.t ........ ok   
t/95_complex_config.t .. ok   
All tests successful.
Files=27, Tests=316, 244 wallclock secs ( 0.15 usr  0.02 sys + 239.13 cusr  5.09 csys = 244.39 CPU)
Result: PASS

It looks to me like there's a mismatched ifcase/fi pair when parsing babel.def, as suggested also by the error message reproduced above.

@dginev

This comment has been minimized.

Collaborator

dginev commented Apr 17, 2018

Yes, the problem is reproducing this, as I don't have your exact texlive installation. But I may be getting closer.

@dginev

This comment has been minimized.

Collaborator

dginev commented Apr 17, 2018

I can reproduce again 👍 will send an update soon

@dginev

This comment has been minimized.

Collaborator

dginev commented Apr 17, 2018

Ok, the key problem here is that LaTeXML's support of conditionals still needs some rope to mimic TeX close enough (cc @brucemiller ).

A minimal demonstration is:

% babel.def
\ifcase\bbl@engine
  \input txtbabel.def
\fi

and then

% txtbabel.def
\ifx\bbl@opt@layout\@nnil\endinput\fi

From my tinkering, it seems that the inner file has its \ifx succeed, and \endinput executes. Due to the conditional implementation, the inner file's Mouth is then flushed, and the final \fi in that file is never read. Which leads to the outer file's \fi macro closing \ifx instead of \ifcase and then we see the error reported.

I don't have a TeXbook near me right now, but I can guess at two ideas to solve this - either add a special case to \endinput that checks for a following \fi (hacky), or instead do whichever defense TeX is using - maybe reset the conditional state back to the outer file's?

I.e. shift from the if_stack all values that were added from the file whose Mouth was just flushed.

@dginev

This comment has been minimized.

Collaborator

dginev commented Apr 17, 2018

Interestingly, if I drop the \fi in the inner file and run pdflatex, I can see a minor warning reading:

(\end occurred when \ifx on line 445 was incomplete)

but the PDF is still produced, and this isn't reported as an error. Maybe that's also something to consider in terms of severity.

@brucemiller

This comment has been minimized.

Owner

brucemiller commented Apr 17, 2018

Ah! Found it in the TeX book: \endinput will stop reading from that file when it reaches the end of the current line! Looks like some hacky version of flushMouth is needed; Ugh!

@dginev

This comment has been minimized.

Collaborator

dginev commented Apr 17, 2018

Horrible! But awesome! Now we know what the right fix is at least, even if we find it magnificently ad-hoc 😂

@swalter62

This comment has been minimized.

swalter62 commented Apr 19, 2018

This resolves the issue for me -- my scripts are working once again. Thanks a million!

@dginev

This comment has been minimized.

Collaborator

dginev commented Apr 19, 2018

Wonderful! And thank you for reporting this issue early - it would have hit all latexml users when the newest texlive becomes the standard in the mainstream distributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment