Skip to content
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

Errors with \LTinput #169

Closed
torik42 opened this issue Jan 26, 2021 · 4 comments
Closed

Errors with \LTinput #169

torik42 opened this issue Jan 26, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@torik42
Copy link
Owner

torik42 commented Jan 26, 2021

Playing a bit around with \LTinput I noticed two things.

If one has two files, which use \LTinput to read each other, then a RecursionError: maximum recursion depth exceeded while calling a Python object occurs. As far as I understand, you check to not load packages twice, then maybe loading the same file with \LTinput twice should be prevented.

When you use \LTinput to read a file and this loaded file yields an error, e.g.

*** LaTeX error: line 2, column 1:
*** could not read file 'a.tex'

from another \LTinput, then the given position is the correct position in the loaded file. But we do not know which file this is. It would be nice if that could be added to the error message.

@matze-dd matze-dd added bug Something isn't working enhancement New feature or request labels Jan 27, 2021
@matze-dd
Copy link
Collaborator

Thanks for these observations. :)

The first should be considered as a bug. Some time ago, I was already wondering about the second point. This would be an improvement.

@matze-dd
Copy link
Collaborator

Contemplating the file recursion problem, I'm wondering about the following. LaTeX macro \input repeatedly includes the files. In order to keep maximum similarities it perhaps might be better to catch the specific exception in the \LTinput macro handler and raise a better error message.

Do you have an application in mind, where we really should read a file only once?

@torik42
Copy link
Owner Author

torik42 commented Jan 28, 2021

I am not sure whether this applies here: Suppose I have a multi file document. Where main.tex uses \input{chapter1.tex} and chapter1.tex has \LTinput{main.tex}. Would this cause any problems? In a quick test I don’t run into recursion here. Does \input also loads \LTinput commands in the inputted file?

Otherwise, just catching the error is fine.

@matze-dd
Copy link
Collaborator

I am not sure whether this applies here: Suppose I have a multi file document. Where main.tex uses \input{chapter1.tex} and chapter1.tex has \LTinput{main.tex}.

Thanks for this clever case. I assume that you define, e.g., macros in the preamble in main.tex that should be available for the filter when processing chapter1.tex.

In a quick test I don’t run into recursion here. Does \input also loads \LTinput commands in the inputted file?

Macros \input and \include are ignored by the base filter yalafi. Only in a first phase, yalafi.shell goes through and collects names of files that are included by these macros. Then, each file is processed on its own using plain yalafi.

Otherwise, just catching the error is fine.

OK, then I will change it this way. Thanks for the feedback!

matze-dd added a commit that referenced this issue Jan 31, 2021
@matze-dd matze-dd removed the bug Something isn't working label Jan 31, 2021
matze-dd added a commit that referenced this issue Jan 31, 2021
Addresses issue #169 (recursion problem)
matze-dd added a commit that referenced this issue Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants