Skip to content

Commit

Permalink
Fix \lastskip,\lastkern by also skipping over any trailing Comment boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
brucemiller committed Oct 8, 2024
1 parent 780e57d commit 2613c5f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions lib/LaTeXML/Engine/TeX_Glue.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,13 @@ DefPrimitiveI('\vfilneg', undef, undef);
#----------------------------------------------------------------------
# \lastskip iq is 0.0 pt or the last glue or muglue on the current list.
DefRegister('\lastskip' => Dimension(0), readonly => 1, getter => sub {
my $box = $LaTeXML::LIST[-1];
return ($box && $box->getProperty('isSkip') ? $box->getProperty('width') : Dimension(0)); });
for (my $i = $#LaTeXML::LIST ; $i > 0 ; $i--) {
my $box = $LaTeXML::LIST[$i];
last if !$box;
next if ref $box eq 'LaTeXML::Core::Comment';
last if !$box->getProperty('isSkip');
return $box->getProperty('width'); }
return Dimension(0); });

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1;
9 changes: 7 additions & 2 deletions lib/LaTeXML/Engine/TeX_Kern.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ DefPrimitiveI('\unkern', undef, sub {

# Get kern, if last on LIST
DefRegister('\lastkern' => Dimension(0), readonly => 1, getter => sub {
my $box = $LaTeXML::LIST[-1];
return ($box && $box->getProperty('isKern') ? $box->getProperty('width') : Dimension(0)); });
for (my $i = $#LaTeXML::LIST ; $i > 0 ; $i--) {
my $box = $LaTeXML::LIST[$i];
last if !$box;
next if ref $box eq 'LaTeXML::Core::Comment';
last if !$box->getProperty('isKern');
return $box->getProperty('width'); }
return Dimension(0); });

#======================================================================
# Moving Vertically
Expand Down

0 comments on commit 2613c5f

Please sign in to comment.