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

Everymath #2461

Merged
merged 5 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Math entering commands no longer need to handle \everymath,\everydisp…
…lay, just beginMode appropriately
  • Loading branch information
brucemiller committed Dec 28, 2024
commit 459dabcc857648d586881e3fa9059198e112507d
13 changes: 4 additions & 9 deletions lib/LaTeXML/Engine/LaTeX.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -2045,13 +2045,9 @@ DefConstructorI('\lx@begin@display@math', undef,
. "</ltx:Math>"
. "</ltx:equation>",
alias => '$$',
beforeDigest => sub {
$_[0]->beginMode('display_math');
if (my $toks = LookupRegister(T_CS('\everydisplay'))) {
$_[0]->getGullet->unread($toks); }
return; },
properties => sub { RefStepID('equation') },
captureBody => 1);
beforeDigest => sub { $_[0]->beginMode('display_math'); },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice simplification. The cherry on the cake would be to switch the few cases of

beforeDigest => sub { $_[0]->beginMode('display_math'); }

to the abbreviated form of

mode => 'display_math'

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! I fell into that trap! (& wasted time). It's subtly different. That short form simply switches the mode (typically within an environment which establishes a grouping), whereas the commands in question like \lx@begin@displaymath come in pairs which will do beginMode and endMode.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! mode also ends the mode at the end, indeed that slipped my mind. Apologies.

properties => sub { RefStepID('equation') },
captureBody => 1);

DefEnvironment('{displaymath}',
"<ltx:equation xml:id='#id'>"
Expand All @@ -2070,8 +2066,7 @@ DefEnvironment('{math}',
. "#body"
. "</ltx:XMath>"
. "</ltx:Math>",
mode => 'inline_math',
);
mode => 'inline_math');

Let('\curr@math@size', '\@empty');

Expand Down
14 changes: 4 additions & 10 deletions lib/LaTeXML/Engine/TeX_Math.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,8 @@ DefConstructorI('\lx@begin@display@math', undef,
. "</ltx:Math>"
. "</ltx:equation>",
reversion => Tokens(T_MATH, T_MATH),
beforeDigest => sub {
$_[0]->beginMode('display_math');
if (my $toks = LookupRegister(T_CS('\everydisplay'))) {
$_[0]->getGullet->unread($toks); }
return; }, captureBody => 1);
beforeDigest => sub { $_[0]->beginMode('display_math'); },
captureBody => 1);
DefConstructorI('\lx@end@display@math', undef, "",
reversion => Tokens(T_MATH, T_MATH),
beforeDigest => sub { $_[0]->endMode('display_math'); });
Expand All @@ -150,11 +147,8 @@ DefConstructorI('\lx@begin@inline@math', undef,
. "</ltx:XMath>"
. "</ltx:Math>",
reversion => Tokens(T_MATH),
beforeDigest => sub {
$_[0]->beginMode('inline_math');
if (my $toks = LookupRegister(T_CS('\everymath'))) {
$_[0]->getGullet->unread($toks); }
return; }, captureBody => 1);
beforeDigest => sub { $_[0]->beginMode('inline_math'); },
captureBody => 1);
DefConstructorI('\\lx@end@inline@math', undef, "",
reversion => Tokens(T_MATH),
beforeDigest => sub { $_[0]->endMode('inline_math'); });
Expand Down