From 2613c5f46cc38933df9c48f5b058257a83b40c31 Mon Sep 17 00:00:00 2001 From: Bruce Miller Date: Tue, 8 Oct 2024 15:58:51 -0400 Subject: [PATCH] Fix \lastskip,\lastkern by also skipping over any trailing Comment boxes --- lib/LaTeXML/Engine/TeX_Glue.pool.ltxml | 9 +++++++-- lib/LaTeXML/Engine/TeX_Kern.pool.ltxml | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/LaTeXML/Engine/TeX_Glue.pool.ltxml b/lib/LaTeXML/Engine/TeX_Glue.pool.ltxml index 78120b1a6..7e8223c06 100644 --- a/lib/LaTeXML/Engine/TeX_Glue.pool.ltxml +++ b/lib/LaTeXML/Engine/TeX_Glue.pool.ltxml @@ -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; diff --git a/lib/LaTeXML/Engine/TeX_Kern.pool.ltxml b/lib/LaTeXML/Engine/TeX_Kern.pool.ltxml index ee308af1a..99428eab8 100644 --- a/lib/LaTeXML/Engine/TeX_Kern.pool.ltxml +++ b/lib/LaTeXML/Engine/TeX_Kern.pool.ltxml @@ -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