-
Notifications
You must be signed in to change notification settings - Fork 108
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
[WIP] TeX-faitfhul errors on undefined command sequence expansion #1182
Conversation
Also, @brucemiller , I suspect rebasing on this branch may offer extra insight into debugging expl3 and other related raw interpretation cases, if we're lucky. Could make it very explicit that expansion is incorrect at a certain point in processing. |
I've verified the showcase Tikz images work with this branch as well, which is reassuring. |
sub neutralizeTokens { | ||
my ($self, @tokens) = @_; | ||
my @result = (); | ||
foreach my $token (@tokens) { | ||
if ($$token[1] == CC_PARAM) { # Inline ->getCatcode! | ||
push(@result, $token); } | ||
elsif (defined(my $defn = LaTeXML::Core::State::lookupDefinition($STATE, $token))) { | ||
elsif (!defined(my $meaning = LaTeXML::Core::State::lookupMeaning($STATE, $token)) || | ||
defined(my $defn = LaTeXML::Core::State::lookupDefinition($STATE, $token))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if this is best left without either check, just always add the \noexpand
. We have an example in the tests that needs \noexpand
added for undefined CSes.
OK, I mixed up responses to PR's. There may be some good fixes here, but there's definitely some fishy stuff (esp. calc, siunitx); it seems a regression. And the motivating issue is about "incorrect" documents, nothing indicates that the issue or patches would change the behavior of a correct document (at least not for the better). It might make debugging easier by failing earlier. |
Ok, I will try to restore at least calculus back to doing Also, I agree this PR shouldn't break existing correct behaviour, not my intention. Was fishing for some feedback 👍 |
9dd4b12
to
f1c00b4
Compare
f1c00b4
to
52a797e
Compare
Ok @brucemiller I struggled some more and partially managed to simplify the binding modifications. The calc in particular should not worry you at all anymore. For the siunitx, I found a piece of trickery as well, but got scared for alignments, and allowed them to keep the old Turns out there are two new best practices one can use to save failing bindings that were leveraging the "expanding undefined command sequences" behavior:
I've only needed them in the files you can see changed in the PR, but we may be missing tests for some of the other bindings... I don't really feel comfortable merging this very soon, but would definitely consider it relevant for the 1.0 milestone. |
Note to self: I should add the two TeX files from the issue as tests, to avoid regressing. |
Closing in favor of #1188 |
Fixes #1180 .
And likely breaks a range of hard-to-foresee arXiv jobs, and third party raw TeX uses. I think my fixes definitely need some review and discussion/thought, as I touched bindings I am not closely familiar with.
The general concept is simple enough - expansion must always have defined command sequence arguments. And all good uses of expansion already do. The breakage in latexml happens at the fringes -- e.g. bindings that take very Perl-y approaches and leave certain command sequences undefined, or raw interpretation that silently ends up accepting invalid inputs where it should alert us with an error that latexml needs further improvement. I gave two examples in the issue of error cases, which now work just the same as in pdflatex with this PR. And tests pass with my modifications.