Skip to content

Commit a46a577

Browse files
committed
When boxes are used (\box), use the correct method of unsetting them
1 parent fca8c70 commit a46a577

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/LaTeXML/Core/State.pm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ sub assign_internal {
169169
else { # Otherwise, push new value & set 1 to be undone
170170
$$self{undo}[0]{$table}{$key} = 1;
171171
unshift(@{ $$self{$table}{$key} }, $value); } } # And push new binding.
172+
elsif ($scope eq 'inplace') { # Special case for \box & friends
173+
if (exists $$self{$table}{$key}) { # If the value was previously assigned AT ALL
174+
$$self{$table}{$key}[0] = $value; } # Simply replace the value in its frame
175+
else { # Otherwise, push new value, like local
176+
$$self{undo}[0]{$table}{$key} = 1;
177+
unshift(@{ $$self{$table}{$key} }, $value); } } # And push new binding.
172178
else {
173179
assign_internal($self, 'stash', $scope, [], 'global') unless $$self{stash}{$scope}[0];
174180
push(@{ $$self{stash}{$scope}[0] }, [$table, $key, $value]);
@@ -834,6 +840,7 @@ determines how the assignment is made. The allowed values and their implication
834840
global : global assignment.
835841
local : local assignment, within the current grouping.
836842
undef : global if \global preceded, else local (default)
843+
inplace : assigns in same frame as previously set (for unsetting \box)
837844
<name> : stores the assignment in a `scope' which
838845
can be loaded later.
839846

lib/LaTeXML/Engine/TeX_Box.pool.ltxml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ DefPrimitive('\box Number', sub {
559559
my $box = 'box' . $_[1]->valueOf;
560560
my $stuff = LookupValue($box);
561561
adjustBoxColor($stuff);
562-
AssignValue($box, undef);
562+
AssignValue($box, undef, 'inplace');
563563
($stuff ? $stuff : List()); });
564564

565565
DefPrimitive('\copy Number', sub {
@@ -573,7 +573,7 @@ DefPrimitive('\unhbox Number', sub {
573573
my $box = 'box' . $_[1]->valueOf;
574574
my $stuff = LookupValue($box);
575575
adjustBoxColor($stuff);
576-
AssignValue($box, undef);
576+
AssignValue($box, undef, 'inplace');
577577
(defined $stuff ? $stuff->unlist : List()); });
578578

579579
DefPrimitive('\unhcopy Number', sub {
@@ -587,7 +587,7 @@ DefPrimitive('\unvbox Number', sub {
587587
my $box = 'box' . $_[1]->valueOf;
588588
my $stuff = LookupValue($box);
589589
adjustBoxColor($stuff);
590-
AssignValue($box, undef);
590+
AssignValue($box, undef, 'inplace');
591591
(defined $stuff ? $stuff->unlist : List()); });
592592

593593
DefPrimitive('\unvcopy Number', sub {

0 commit comments

Comments
 (0)