From aba805b8aec99f5e7d0be395cb69b8052d9cf9da Mon Sep 17 00:00:00 2001 From: bruce miller Date: Wed, 9 Oct 2024 08:57:12 -0400 Subject: [PATCH] Simplify \lastskip,\lastkern (suggested by D.Ginev) (#2424) * Simplify \lastskip,\lastkern (suggested by D.Ginev) * Fix \lastskip,\lastkern by also skipping over any trailing Comment boxes --- lib/LaTeXML/Engine/TeX_Glue.pool.ltxml | 5 +++-- lib/LaTeXML/Engine/TeX_Kern.pool.ltxml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/LaTeXML/Engine/TeX_Glue.pool.ltxml b/lib/LaTeXML/Engine/TeX_Glue.pool.ltxml index 002e2940a..7e8223c06 100644 --- a/lib/LaTeXML/Engine/TeX_Glue.pool.ltxml +++ b/lib/LaTeXML/Engine/TeX_Glue.pool.ltxml @@ -137,10 +137,11 @@ 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; for (my $i = $#LaTeXML::LIST ; $i > 0 ; $i--) { my $box = $LaTeXML::LIST[$i]; - last if !$box || !$box->getProperty('isSkip'); + last if !$box; + next if ref $box eq 'LaTeXML::Core::Comment'; + last if !$box->getProperty('isSkip'); return $box->getProperty('width'); } return Dimension(0); }); diff --git a/lib/LaTeXML/Engine/TeX_Kern.pool.ltxml b/lib/LaTeXML/Engine/TeX_Kern.pool.ltxml index 296f27811..99428eab8 100644 --- a/lib/LaTeXML/Engine/TeX_Kern.pool.ltxml +++ b/lib/LaTeXML/Engine/TeX_Kern.pool.ltxml @@ -65,10 +65,11 @@ DefPrimitiveI('\unkern', undef, sub { # Get kern, if last on LIST DefRegister('\lastkern' => Dimension(0), readonly => 1, getter => sub { - my $box; for (my $i = $#LaTeXML::LIST ; $i > 0 ; $i--) { my $box = $LaTeXML::LIST[$i]; - last if !$box || !$box->getProperty('isKern'); + last if !$box; + next if ref $box eq 'LaTeXML::Core::Comment'; + last if !$box->getProperty('isKern'); return $box->getProperty('width'); } return Dimension(0); });