texlive[58448] branches/branch2020.0/Master/texmf-dist: lua-typo

commits+karl at tug.org commits+karl at tug.org
Tue Mar 16 23:14:34 CET 2021


Revision: 58448
          http://tug.org/svn/texlive?view=revision&revision=58448
Author:   karl
Date:     2021-03-16 23:14:34 +0100 (Tue, 16 Mar 2021)
Log Message:
-----------
lua-typo (16mar21) (branch)

Modified Paths:
--------------
    branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/README.md
    branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-fr.pdf
    branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo.pdf
    branches/branch2020.0/Master/texmf-dist/source/lualatex/lua-typo/lua-typo.dtx
    branches/branch2020.0/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty

Added Paths:
-----------
    branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.pdf
    branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.tex

Removed Paths:
-------------
    branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/demo.pdf
    branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/demo.tex

Modified: branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/README.md
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/README.md	2021-03-16 22:14:13 UTC (rev 58447)
+++ branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/README.md	2021-03-16 22:14:34 UTC (rev 58448)
@@ -20,7 +20,7 @@
 License
 -------
 
-Released under the LaTeX Project Public License v1.3 or later
+Released under the LaTeX Project Public License v1.3c or later
 See http://www.latex-project.org/lppl.txt
 for the details of that license.
 
@@ -50,6 +50,11 @@
 
 - First release version: 0.30, March 2021.
 
+- v.0.32: bug fixes
+  better protection against nil nodes,
+  new page detection corrected,
+  homeoarchy detection improved.
+
 --
 Copyright 2020--2021 Daniel Flipo
 E-mail: daniel (dot) flipo (at) free (dot) fr

Deleted: branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/demo.pdf
===================================================================
(Binary files differ)

Deleted: branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/demo.tex
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/demo.tex	2021-03-16 22:14:13 UTC (rev 58447)
+++ branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/demo.tex	2021-03-16 22:14:34 UTC (rev 58448)
@@ -1,89 +0,0 @@
-\documentclass[a6paper,french,11pt,twoside]{scrartcl}
-\usepackage{scrlayer-scrpage}
-\lohead{Pierre Desproges}
-\lehead{Vivons heureux…}
-\rohead{}
-\rehead{en attendant la mort}
-\usepackage{fourier-otf}
-\usepackage{microtype}
-
-\usepackage{babel}
-\frenchsetup{og=«, fg=»}
-
-\usepackage[All]{lua-typo}   % APRÈS babel / polyglossia
-
-% Mots courts (deux lettres max) à éviter en fin de ligne
-\luatypoOneChar{french}{'À à Ô'}
-\luatypoTwoChars{french}{"Je Tu Il On"}
-
-% Pour changer les couleurs :
-%\usepackage[svgnames]{xcolor}
-%\LuaTypoSetColor1{Fuchsia}
-%\LuaTypoSetColor2{ForestGreen}
-%\LuaTypoSetColor5{magenta}
-%\LuaTypoSetColor6{yellow}
-
-% Réglage ligne finale trop courte
-\setlength{\luatypoLLminWD}{3em}
-
-%\luatypoPageMin=5
-%\luatypoHyphMax=2
-
-\parindent=1em
-
-\begin{document}
-
-Le plus effroyablement démuni des pauvres peut toujours espérer
-\footnote{Overfull hbox  à la ligne précédente.}
-décrocher un jour le gros lot de la tombola organisée par
-l’association des Pauvres Effroyablement Démunis.
-%
-Le laideron lui, n’a d’autre échappatoire que de
-ronger son frein d’un bec-de-lièvre machinal, de baisser ses yeux quelconques
-aux abords des mirroirs qui l’insultent ou de se foutre à l’eau au risque
-d’effaroucher les murènes.
-
-Quelquefois je trouve que Dieu pousse un peu.
-
-« Les hommes naissent libres et égaux en droit. »
-
-Qu’on me pardonne mais c’est un phrase que j’ai beaucoup de mal à dire sans
-rire. % : « Les hommes naissent libres et égaux en droit. »
-
-Prenons une star, une belle star. Elle est belle.
-
-La beauté. Existe-t-il au monde un privilège plus exorbitant que la beauté ?
-
-Par sa beauté, cette femme n’est-elle pas un peu plus libre
-et un peu plus égale , dans le grand combat pour survivre,
-que l’\textit{Homo sapiens} moyen qui passe sa vie à se courir
-après la queue en attendant la mort ?
-
-Quel profond imbécile aurait l’outrecuidance de soutenir, au nom des grands
-principes révolutionnaires, que l’immonde boudin trapu qui m’a
-%collé une contredanse
-lâchement verbalisé
-tout-à-l’heure
-possède les mêmes armes
-%pour assoir son bonheur terrestre
-que la grande fille féline aux charmes troubles où l’œil se
-pose et chancelle avec une lubricité contenue !
-%(Difficilement contenue.)  % Variantes pour mettre 1 ou 2 car. en bout de ligne
-%(Difficilement contenue hein). Je dois le dire.
-%(Difficilement contenue hein). On peut le dire.
-%(Difficilement contenue hein). Il faut l’admettre.
-(Difficilement contenue hein). À voir.
-
-Quand on a vos yeux, madame, quand on a votre bouche, votre grain de peau, la
-légèreté diaphane de votre démarche et la longueur émouvante de vos cuisses,
-c’est une banalité de dire qu’on peut facilement traverser la vie %l’existence
-à l’abri des cabats trop lourds gorgés de poireaux, à l’écart de l’uniforme de
-contractuelle.
-
-\end{document}
-
-%%% Local Variables:
-%%% coding: utf-8-unix
-%%% TeX-master: t
-%%% TeX-engine: luatex
-%%% End:

Added: branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.pdf
===================================================================
(Binary files differ)

Index: branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.pdf
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.pdf	2021-03-16 22:14:13 UTC (rev 58447)
+++ branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.pdf	2021-03-16 22:14:34 UTC (rev 58448)

Property changes on: branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.tex
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.tex	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.tex	2021-03-16 22:14:34 UTC (rev 58448)
@@ -0,0 +1,89 @@
+\documentclass[a6paper,french,11pt,twoside]{scrartcl}
+\usepackage{scrlayer-scrpage}
+\lohead{Pierre Desproges}
+\lehead{Vivons heureux…}
+\rohead{}
+\rehead{en attendant la mort}
+\usepackage{fourier-otf}
+\usepackage{microtype}
+
+\usepackage{babel}
+\frenchsetup{og=«, fg=»}
+
+\usepackage[All]{lua-typo}   % APRÈS babel / polyglossia
+
+% Mots courts (deux lettres max) à éviter en fin de ligne
+\luatypoOneChar{french}{'À à Ô'}
+\luatypoTwoChars{french}{"Je Tu Il On"}
+
+% Pour changer les couleurs :
+%\usepackage[svgnames]{xcolor}
+%\LuaTypoSetColor1{Fuchsia}
+%\LuaTypoSetColor2{ForestGreen}
+%\LuaTypoSetColor5{magenta}
+%\LuaTypoSetColor6{yellow}
+
+% Réglage ligne finale trop courte
+\setlength{\luatypoLLminWD}{3em}
+
+%\luatypoPageMin=5
+%\luatypoHyphMax=2
+
+\parindent=1em
+
+\begin{document}
+
+Le plus effroyablement démuni des pauvres peut toujours espérer
+\footnote{Overfull hbox  à la ligne précédente.}
+décrocher un jour le gros lot de la tombola organisée par
+l’association des Pauvres Effroyablement Démunis.
+%
+Le laideron lui, n’a d’autre échappatoire que de
+ronger son frein d’un bec-de-lièvre machinal, de baisser ses yeux quelconques
+aux abords des mirroirs qui l’insultent ou de se foutre à l’eau au risque
+d’effaroucher les murènes.
+
+Quelquefois je trouve que Dieu pousse un peu.
+
+« Les hommes naissent libres et égaux en droit. »
+
+Qu’on me pardonne mais c’est un phrase que j’ai beaucoup de mal à dire sans
+rire. % : « Les hommes naissent libres et égaux en droit. »
+
+Prenons une star, une belle star. Elle est belle.
+
+La beauté. Existe-t-il au monde un privilège plus exorbitant que la beauté ?
+
+Par sa beauté, cette femme n’est-elle pas un peu plus libre
+et un peu plus égale , dans le grand combat pour survivre,
+que l’\textit{Homo sapiens} moyen qui passe sa vie à se courir
+après la queue en attendant la mort ?
+
+Quel profond imbécile aurait l’outrecuidance de soutenir, au nom des grands
+principes révolutionnaires, que l’immonde boudin trapu qui m’a
+%collé une contredanse
+lâchement verbalisé
+tout-à-l’heure
+possède les mêmes armes
+%pour assoir son bonheur terrestre
+que la grande fille féline aux charmes troubles où l’œil se
+pose et chancelle avec une lubricité contenue !
+%(Difficilement contenue.)  % Variantes pour mettre 1 ou 2 car. en bout de ligne
+%(Difficilement contenue hein). Je dois le dire.
+%(Difficilement contenue hein). On peut le dire.
+%(Difficilement contenue hein). Il faut l’admettre.
+(Difficilement contenue hein). À voir.
+
+Quand on a vos yeux, madame, quand on a votre bouche, votre grain de peau, la
+légèreté diaphane de votre démarche et la longueur émouvante de vos cuisses,
+c’est une banalité de dire qu’on peut facilement traverser la vie %l’existence
+à l’abri des cabats trop lourds gorgés de poireaux, à l’écart de l’uniforme de
+contractuelle.
+
+\end{document}
+
+%%% Local Variables:
+%%% coding: utf-8-unix
+%%% TeX-master: t
+%%% TeX-engine: luatex
+%%% End:


Property changes on: branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-fr.pdf
===================================================================
(Binary files differ)

Modified: branches/branch2020.0/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo.pdf
===================================================================
(Binary files differ)

Modified: branches/branch2020.0/Master/texmf-dist/source/lualatex/lua-typo/lua-typo.dtx
===================================================================
--- branches/branch2020.0/Master/texmf-dist/source/lualatex/lua-typo/lua-typo.dtx	2021-03-16 22:14:13 UTC (rev 58447)
+++ branches/branch2020.0/Master/texmf-dist/source/lualatex/lua-typo/lua-typo.dtx	2021-03-16 22:14:34 UTC (rev 58448)
@@ -1,4 +1,4 @@
-% \CheckSum{337}
+% \CheckSum{336}
 %
 % \iffalse meta-comment
 %
@@ -34,6 +34,7 @@
 \postamble
 \endpostamble
 \let\MetaPrefix\DoubleperCent
+\askforoverwritefalse
 \generate{%
    \file{lua-typo.sty}{\from{lua-typo.dtx}{sty}}% {sty,msg,dbg}
    \nopreamble
@@ -618,7 +619,7 @@
 \ProvidesFile{lua-typo.dtx}
 %</dtx>
 %<*dtx|sty>
-                [2021/03/03 v.0.30 Daniel Flipo]
+                [2021/03/14 v.0.32 Daniel Flipo]
 %</dtx|sty>
 %<*sty>
 % \fi
@@ -841,7 +842,7 @@
 }
 %    \end{macrocode}
 %
-%    Print the summary of offending pages ---if any-- at the
+%    Print the summary of offending pages ---if any--- at the
 %    (very) end of document unless option |None| has been selected.
 %
 %    \begin{macrocode}
@@ -864,8 +865,8 @@
        texio.write_nl('*** lua-typo: No Typo Flaws found.')
     else
        texio.write_nl('*** lua-typo: WARNING *************')
-       texio.write_nl('The following pages need attention: '
-                      .. luatypo.pagelist)
+       texio.write_nl('The following pages need attention: ')
+       texio.write(luatypo.pagelist)
     end
     texio.write_nl('***********************************')
     texio.write_nl(' ')
@@ -955,6 +956,7 @@
 local parlines = 0
 local pagelines = 0
 local pageno = 0
+local prevno = 0
 local pageflag = false
 
 local char_to_discard = { }
@@ -972,6 +974,8 @@
 split_lig[0xFB02] = "fl"
 split_lig[0xFB03] = "ffi"
 split_lig[0xFB04] = "ffl"
+split_lig[0xFB05] = "st"
+split_lig[0xFB06] = "st"
 
 local DISC  = node.id("disc")
 local GLYPH = node.id("glyph")
@@ -982,7 +986,7 @@
 local MKERN = node.id("margin_kern")
 local PENALTY = node.id("penalty")
 % \end{macrocode}
-%    GLUE subtypes:
+%    Glue subtypes:
 %    \begin{macrocode}
 local USRSKIP  = 0
 local PARSKIP  = 3
@@ -991,7 +995,7 @@
 local TOPSKIP = 10
 local PARFILL = 15
 % \end{macrocode}
-%    HLIST subtypes:
+%    Hlist subtypes:
 %    \begin{macrocode}
 local LINE    = 1
 local BOX     = 2
@@ -1000,6 +1004,10 @@
 %    \begin{macrocode}
 local USER = 0
 local HYPH = 0x2D
+%    \end{macrocode}
+%    Glyph subtypes:
+%    \begin{macrocode}
+local LIGA = 0x102
 
 local effective_glue = node.effective_glue
 local set_attribute = node.set_attribute
@@ -1018,24 +1026,24 @@
 %    \begin{macrocode}
 local color_node = function (node, color)
   local attr = oberdiek.luacolor.getattribute()
-  if node.id == DISC then
+  if node and node.id == DISC then
      local pre = node.pre
      local post = node.post
-     local replace = node.replace
+     local repl = node.replace
      if pre then
         set_attribute(pre,attr,color)
-%<dbg>     texio.write_nl('PRE=' .. tostring(pre.char))
+%<dbg>  texio.write_nl('PRE=' .. tostring(pre.char))
      end
      if post then
         set_attribute(post,attr,color)
-%<dbg>     texio.write_nl('POST=' .. tostring(post.char))
+%<dbg>  texio.write_nl('POST=' .. tostring(post.char))
      end
-     if replace then
-        set_attribute(replace,attr,color)
-%<dbg>     texio.write_nl('REPL=' .. tostring(replace.char))
+     if repl then
+        set_attribute(repl,attr,color)
+%<dbg>  texio.write_nl('REPL=' .. tostring(repl.char))
      end
 %<dbg>     texio.write_nl(' ')
-  else
+  elseif node then
      set_attribute(node,attr,color)
   end
 end
@@ -1051,6 +1059,7 @@
       color_node(n, color)
   end
 end
+%    \end{macrocode}
 %
 %    This auxillary function colours a whole line. It requires two
 %    arguments: a line’s node and a (named) colour.
@@ -1059,7 +1068,7 @@
 local color_line = function (head, color)
   local first = head.head
   for n in traverse(first) do
-      if n.id == HLIST and n.subtype == BOX then
+      if n and n.id == HLIST and n.subtype == BOX then
          color_hbox(n, color)
       else
          color_node(n, color)
@@ -1084,7 +1093,7 @@
 local signature = function (node, string, swap)
   local n = node
   local str = string
-  if n.id == GLYPH then
+  if n and n.id == GLYPH then
     local b, id = is_glyph(n)
     if b and not char_to_discard[b] then
 %    \end{macrocode}
@@ -1091,7 +1100,7 @@
 %    Punctuation has to be discarded; the French apostrophe (right quote
 %    U+2019) has a char code ``out of range’’, we replace it with U+0027;
 %    Other glyphs should have char codes less than 0x100 (or 0x180?) or
-%    be ligatures… standard ones (U+FB00 to U+FB04) are converted using
+%    be ligatures… standard ones (U+FB00 to U+FB06) are converted using
 %    table |split_lig|.
 %    \begin{macrocode}
        if b == 0x2019 then b = 0x27 end
@@ -1103,9 +1112,19 @@
              c = string.reverse(c)
           end
           str = str .. c
+%    \end{macrocode}
+%    Experimental: store other ligatures as the last two digits of their
+%    decimal code…
+%    \begin{macrocode}
+       elseif n.subtype == LIGA and b > 0xE000 then
+          local c = string.sub(b,-2)
+          if swap then
+             c = string.reverse(c)
+          end
+          str = str .. c
        end
     end
-  elseif n.id == DISC then
+  elseif n and n.id == DISC then
 %    \end{macrocode}
 %    Ligatures are split into |pre| and |post| and both parts are
 %    stored. In case of \emph{ffl, ffi}, the post part is also
@@ -1129,12 +1148,18 @@
        end
     end
     if swap then
-       str = str .. c2  .. c1
+       str = str .. c2 .. c1
     else
        str = str .. c1 .. c2
     end
   end
+%    \end{macrocode}
+%    The returned length is the number of \emph{letters}.
+%    \begin{macrocode}
   local len = string.len(str)
+  if string.find(str, "_") then
+     len = len - 1
+  end
   return len, str
 end
 %    \end{macrocode}
@@ -1150,15 +1175,14 @@
 local check_last_word = function (old, node, color, flag)
   local match = false
   local new = ""
-  local len = 0
-  if flag then
+  local maxlen = 0
+  if flag and node then
+     local swap = true
 %    \end{macrocode}
-%    Get the last glyph one the line, skipping discretionaries,
-%    margin kerns, etc., unless |flag| cancels the whole process.
+%    Step back to the last glyph or discretionary.
 %    \begin{macrocode}
-     local swap = true
      local lastn = node
-     while lastn and lastn.id ~= GLYPH and lastn.prev do
+     while lastn and lastn.id ~= GLYPH and lastn.id ~= DISC do
        lastn = lastn.prev
      end
 %    \end{macrocode}
@@ -1165,17 +1189,16 @@
 %    A signature is built from the last two words on the current line.
 %    \begin{macrocode}
      local n = lastn
-     repeat
-       len, new = signature (n, new, swap)
+     while n and n.id ~= GLUE do
+       maxlen, new = signature (n, new, swap)
        n = n.prev
-     until not n or n.id == GLUE
+     end
      if n and n.id == GLUE then
         new = new .. "_"
-        len = len + 1
         repeat
           n = n.prev
-          len, new = signature (n, new, swap)
-        until n.id == GLUE or not n.prev
+          maxlen, new = signature (n, new, swap)
+        until not n or n.id == GLUE
      end
      new = string.reverse(new)
 %<dbg>  texio.write_nl('EOLsigold=' .. old)
@@ -1184,24 +1207,24 @@
      local MinPart = luatypo.MinPart
      MinFull = math.min(MinPart,MinFull)
      local k = MinPart
-     local oldlast = string.gsub (old, '%w+_', '')
-     local newlast = string.gsub (new, '%w+_', '')
-     len = string.len(newlast)
-     if len < MinPart then
+     local oldlast = string.gsub (old, '.*_', '')
+     local newlast = string.gsub (new, '.*_', '')
+     local i = string.find(new, "_")
+     if i and i > maxlen - MinPart + 1 then
         k = MinPart + 1
      end
      local oldsub = string.sub(old,-k)
      local newsub = string.sub(new,-k)
-     local maxlen = string.len(new)
-     if oldsub == newsub then
+     local l = string.len(new)
+     if oldsub == newsub and l >= k then
 %<dbg>  texio.write_nl('EOLnewsub=' .. newsub)
         match = true
-     elseif oldlast == newlast and len >= MinFull then
+     elseif oldlast == newlast and string.len(newlast) >= MinFull then
 %<dbg>  texio.write_nl('EOLnewlast=' .. newlast)
         match = true
         oldsub = oldlast
         newsub = newlast
-        k = len
+        k = string.len(newlast)
      end
      if match then
 %    \end{macrocode}
@@ -1209,7 +1232,7 @@
 %    \begin{macrocode}
         local osub = oldsub
         local nsub = newsub
-        while osub == nsub and k < maxlen do
+        while osub == nsub and k <= maxlen do
           k = k +1
           osub = string.sub(old,-k)
           nsub = string.sub(new,-k)
@@ -1217,8 +1240,9 @@
              newsub = nsub
           end
         end
+        newsub = string.gsub(newsub, '^_', '')
 %<dbg>     texio.write_nl('EOLfullmatch=' .. newsub)
-%<msg>     texio.write_nl('***MATCH=' .. newsub ..
+%<msg>     texio.write_nl('***EOLMATCH=' .. newsub ..
 %<msg>                              " on page " .. pageno)
 %<msg>     texio.write_nl(' ')
 %    \end{macrocode}
@@ -1226,18 +1250,16 @@
 %    \begin{macrocode}
         oldsub = string.reverse(newsub)
         local newsub = ""
-        local k = string.len(oldsub)
         local n = lastn
         repeat
           if n and n.id ~= GLUE then
              color_node(n, color)
-             len, newsub = signature(n, newsub, swap)
+             l, newsub = signature(n, newsub, swap)
           elseif n then
              newsub = newsub .. "_"
-             len = len + 1
           end
           n = n.prev
-        until not n or newsub == oldsub or len >= k
+        until not n or newsub == oldsub or l >= k
      end
   end
   return new, match
@@ -1252,19 +1274,23 @@
   local match = false
   local swap = false
   local new = ""
-  local len = 0
+  local maxlen = 0
   local start = node
   local n = start
-  while n and n.id ~= GLUE do
-    len, new = signature (n, new, swap)
-    n = n.next
+  while n and n.id ~= GLYPH and n.id ~= DISC do
+     n = n.next
   end
-  n = n.next
-  new = new .. "_"
   while n and n.id ~= GLUE do
-    len, new = signature (n, new, swap)
+    maxlen, new = signature (n, new, swap)
     n = n.next
   end
+  if n and n.id == GLUE then
+     new = new .. "_"
+     repeat
+       n = n.next
+       maxlen, new = signature (n, new, swap)
+     until not n or n.id == GLUE
+  end
 %<dbg>  texio.write_nl('BOLsigold=' .. old)
 %<dbg>  texio.write('   BOLsig=' .. new)
 %    \end{macrocode}
@@ -1277,28 +1303,26 @@
      local MinPart = luatypo.MinPart
      MinFull = math.min(MinPart,MinFull)
      local k = MinPart
-     local L = MinPart -1
      local oldsub = ""
      local newsub = ""
-     local oldfirst = string.gsub (old, '_%w+', '')
-     local newfirst = string.gsub (new, '_%w+', '')
-     len = string.len(newfirst)
-     if len < MinPart then
+     local oldfirst = string.gsub (old, '_.*', '')
+     local newfirst = string.gsub (new, '_.*', '')
+     local i = string.find(new, "_")
+     if i and i <= MinPart then
         k = MinPart + 1
      end
-     local maxlen = string.len(new)
-     local oldsub = string.sub(old,1,L)
-     local newsub = string.sub(new,1,L)
-     if oldsub == newsub then
+     local oldsub = string.sub(old,1,k)
+     local newsub = string.sub(new,1,k)
+     local l = string.len(newsub)
+     if oldsub == newsub and l >= k then
 %<dbg>  texio.write_nl('BOLnewsub=' .. newsub)
         match = true
-        k = L
-     elseif oldfirst == newfirst  and len >= MinFull then
+     elseif oldfirst == newfirst  and string.len(newfirst) >= MinFull then
 %<dbg>  texio.write_nl('BOLnewfirst=' .. newfirst)
         match = true
         oldsub = oldfirst
         newsub = newfirst
-        k = len
+        k = string.len(newfirst)
      end
      if match then
 %    \end{macrocode}
@@ -1306,7 +1330,7 @@
 %    \begin{macrocode}
         local osub = oldsub
         local nsub = newsub
-        while osub == nsub and k < maxlen do
+        while osub == nsub and k <= maxlen do
           k = k + 1
           osub = string.sub(old,1,k)
           nsub = string.sub(new,1,k)
@@ -1314,15 +1338,11 @@
              newsub = nsub
           end
         end
-        if k < MinPart then
-           match =false
-        end
-     end
-     if match then
-%<dbg>     texio.write_nl('BOLfullmatch=' .. newsub)
-%<msg>     texio.write_nl('***MATCH=' .. newsub ..
-%<msg>                              " on page " .. pageno)
-%<msg>     texio.write_nl(' ')
+        newsub = string.gsub(newsub, '_$', '')   --$
+%<dbg>  texio.write_nl('BOLfullmatch=' .. newsub)
+%<msg>  texio.write_nl('***BOLMATCH=' .. newsub ..
+%<msg>                           " on page " .. pageno)
+%<msg>  texio.write_nl(' ')
 %    \end{macrocode}
 %    Lest's colour the matching string.
 %    \begin{macrocode}
@@ -1333,13 +1353,12 @@
         repeat
           if n and n.id ~= GLUE then
              color_node(n, color)
-             len, newsub = signature(n, newsub, swap)
+             l, newsub = signature(n, newsub, swap)
           elseif n then
              newsub = newsub .. "_"
-             len = len + 1
           end
           n = n.next
-        until not n or newsub == oldsub or len >= k
+        until not n or newsub == oldsub or l >= k
      end
   end
   return new, match
@@ -1370,9 +1389,9 @@
         match = string.find(luatypo.single[lang], string.char(lchar))
         if match then
            color_node(glyph,COLOR)
-%<msg>   texio.write_nl('***MATCH=' .. string.char(lchar) ..
-%<msg>                            " on page " .. pageno)
-%<msg>   texio.write_nl(' ')
+%<msg>     texio.write_nl('***RGXMATCH=' .. string.char(lchar) ..
+%<msg>                              " on page " .. pageno)
+%<msg>     texio.write_nl(' ')
         end
      end
   end
@@ -1392,7 +1411,7 @@
            if match then
               color_node(previous,COLOR)
               color_node(glyph,COLOR)
-%<msg>        texio.write_nl('***MATCH=' .. pattern ..
+%<msg>        texio.write_nl('***RGXMATCH=' .. pattern ..
 %<msg>                                 " on page " .. pageno)
 %<msg>        texio.write_nl(' ')
            end
@@ -1411,7 +1430,7 @@
               if match then
                  color_node(pprev,COLOR)
                  color_node(glyph,COLOR)
-%<msg>           texio.write_nl('***MATCH=' .. pattern ..
+%<msg>           texio.write_nl('***RGXMATCH=' .. pattern ..
 %<msg>                                    " on page " .. pageno)
 %<msg>           texio.write_nl(' ')
               end
@@ -1430,7 +1449,7 @@
 %    \begin{macrocode}
 local show_pre_disc = function (disc, color)
   local n = disc
-  while n.id ~= GLUE do
+  while n and n.id ~= GLUE do
     color_node(n, color)
     n = n.prev
   end
@@ -1485,13 +1504,16 @@
 %    |hyphcount| hold the number the consecutive hyphenated lines.
 %    \begin{macrocode}
     if head.id == GLUE and head.subtype == TOPSKIP then
-       pageflag = false
-       match1 = false
        pageno = tex.getcount("c at page")
        hyphcount = 0
-       pagelines = 0
-       firstwd = ""
-       lastwd = ""
+       if pageno > prevno then
+          pageflag = false
+          pagelines = 0
+          match1 = false
+          firstwd = ""
+          lastwd = ""
+          prevno = pageno
+       end
     elseif head.id == HLIST and head.subtype == LINE then
 %    \end{macrocode}
 %    The current node is a line, |first| is the line’s first node.
@@ -1507,30 +1529,34 @@
 %    \end{macrocode}
 %    Is this line really a text line (one glyph at least)?
 %    \begin{macrocode}
-       local textline = true
-       local n = first
-       while (n and n.id ~= GLYPH) and
-             not (n.id == GLUE and n.subtype == RGTSKIP) do
-         n = n.next
+       local textline = false
+       if first.id == GLYPH then
+          textline = true
+       else
+          local n = first
+          repeat
+            n = n.next
+            if n and n.id == GLYPH then
+               textline = true
+               break
+            end
+          until not n or (n.id == GLUE and n.subtype == RGTSKIP)
        end
-       if n.id == GLUE then
-          textline = false
-       end
 %    \end{macrocode}
 %    Is this line overfull or underfull?
 %    \begin{macrocode}
        if head.glue_set == 1 and head.glue_sign == 2 and
           head.glue_order == 0 and OverfullLines then
-%<msg>  texio.write_nl('***OVERFULL line on page ' .. pageno)
-%<msg>  texio.write_nl(' ')
+%<msg>    texio.write_nl('***OVERFULL line on page ' .. pageno)
+%<msg>    texio.write_nl(' ')
           pageflag = true
           local COLOR = luatypo.colortbl[7]
           color_line (head, COLOR)
        elseif head.glue_set >= Stretch and head.glue_sign == 1 and
               head.glue_order == 0  and UnderfullLines then
-%<msg>  texio.write_nl('***UNDERFULL line on page ' ..
-%<msg>                                    tex.getcount("c at page"))
-%<msg>  texio.write_nl(' ')
+%<msg>    texio.write_nl('***UNDERFULL line on page ' ..
+%<msg>                                      tex.getcount("c at page"))
+%<msg>    texio.write_nl(' ')
           local COLOR = luatypo.colortbl[8]
           pageflag = true
           color_line (head, COLOR)
@@ -1540,7 +1566,7 @@
 %    \begin{macrocode}
        if first.id == LPAR then
 %    \end{macrocode}
-%    It starts a paragraph,
+%    It starts a paragraph…
 %    \begin{macrocode}
           hyphcount = 0
           parlines = 1
@@ -1586,7 +1612,7 @@
           orphanflag = false
 %    \end{macrocode}
 %    but it is a widow if it is the page’s first line and it does’nt
-%    start a new paragraph. Orphans and widows will be colored later.
+%    start a new paragraph.\\ Orphans and widows will be colored later.
 %    \begin{macrocode}
           if pagelines == 1 and parlines > 1 then
              widowflag = true
@@ -1605,8 +1631,8 @@
 %    |llwd| is the line’s length. Is it too short?
 %    \begin{macrocode}
              if llwd < LLminWD then
-%<msg>     texio.write_nl('***Last line too short, page ' .. pageno)
-%<msg>     texio.write_nl(' ')
+%<msg>          texio.write_nl('***Last line too short, page ' .. pageno)
+%<msg>          texio.write_nl(' ')
                 pageflag = true
                 local COLOR  = luatypo.colortbl[6]
                 local attr = oberdiek.luacolor.getattribute()
@@ -1620,8 +1646,8 @@
 %    Is this line nearly full? (ending too close to the right margin)
 %    \begin{macrocode}
           if BackParindent and PFskip < BackPI and PFskip > BackFuzz then
-%<msg>     texio.write_nl('***Last line nearly full, page ' .. pageno)
-%<msg>     texio.write_nl(' ')
+%<msg>       texio.write_nl('***Last line nearly full, page ' .. pageno)
+%<msg>       texio.write_nl(' ')
              pageflag = true
              local COLOR  = luatypo.colortbl[12]
              local attr = oberdiek.luacolor.getattribute()
@@ -1657,8 +1683,8 @@
              local COLOR = luatypo.colortbl[2]
              local pg = show_pre_disc (pn,COLOR)
              pageflag = true
-%<msg>     texio.write_nl('***HYPH issue page ' .. pageno)
-%<msg>     texio.write_nl(' ')
+%<msg>       texio.write_nl('***HYPH issue page ' .. pageno)
+%<msg>       texio.write_nl(' ')
           end
           if not nextnode and EOPHyphens then
 %    \end{macrocode}
@@ -1758,9 +1784,9 @@
        if lwhyphflag and EOPHyphens then
 %<msg>    texio.write_nl('***LAST WORD SPLIT page ' .. pageno)
 %<msg>    texio.write_nl(' ')
+          pageflag = true
           local COLOR = luatypo.colortbl[1]
           local pg = show_pre_disc (pn,COLOR)
-          pageflag = true
        end
 %    \end{macrocode}
 %    Track empty pages: check the number of lines at end of page.
@@ -1776,11 +1802,13 @@
 %<msg>    texio.write_nl('***Only ' .. pagelines ..
 %<msg>                          ' lines on page ' .. pageno)
 %<msg>    texio.write_nl(' ')
-          local node = head
-          while node.id ~= HLIST or node.subtype ~= LINE do
-             node = node.prev
+          local n = head
+          while n and (n.id ~= HLIST or n.subtype ~= LINE) do
+             n = n.prev
           end
-          color_line(node, COLOR)
+          if n then
+             color_line(n, COLOR)
+          end
        end
     end
   head = nextnode
@@ -1787,9 +1815,14 @@
   end
 %    \end{macrocode}
 %    Add this page number to the summary if any flaw has been found on it.
+%    Skip duplicates.
 %    \begin{macrocode}
   if pageflag then
-     luatypo.pagelist = luatypo.pagelist .. tostring(pageno) .. ", "
+     local pl = luatypo.pagelist
+     local p = tonumber(string.match(pl, "%s(%d+),%s$"))
+     if not p or pageno > p then
+        luatypo.pagelist = luatypo.pagelist .. tostring(pageno) .. ", "
+     end
   end
   return true
 end

Modified: branches/branch2020.0/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty
===================================================================
--- branches/branch2020.0/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty	2021-03-16 22:14:13 UTC (rev 58447)
+++ branches/branch2020.0/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty	2021-03-16 22:14:34 UTC (rev 58448)
@@ -8,7 +8,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[2020/01/01]
 \ProvidesPackage{lua-typo}
-                [2021/03/03 v.0.30 Daniel Flipo]
+                [2021/03/14 v.0.32 Daniel Flipo]
 \ifdefined\directlua
   \RequirePackage{luatexbase,luacode,luacolor}
   \RequirePackage{kvoptions,atveryend}
@@ -202,8 +202,8 @@
        texio.write_nl('*** lua-typo: No Typo Flaws found.')
     else
        texio.write_nl('*** lua-typo: WARNING *************')
-       texio.write_nl('The following pages need attention: '
-                      .. luatypo.pagelist)
+       texio.write_nl('The following pages need attention: ')
+       texio.write(luatypo.pagelist)
     end
     texio.write_nl('***********************************')
     texio.write_nl(' ')
@@ -259,6 +259,7 @@
 local parlines = 0
 local pagelines = 0
 local pageno = 0
+local prevno = 0
 local pageflag = false
 
 local char_to_discard = { }
@@ -276,6 +277,8 @@
 split_lig[0xFB02] = "fl"
 split_lig[0xFB03] = "ffi"
 split_lig[0xFB04] = "ffl"
+split_lig[0xFB05] = "st"
+split_lig[0xFB06] = "st"
 
 local DISC  = node.id("disc")
 local GLYPH = node.id("glyph")
@@ -295,6 +298,7 @@
 local BOX     = 2
 local USER = 0
 local HYPH = 0x2D
+local LIGA = 0x102
 
 local effective_glue = node.effective_glue
 local set_attribute = node.set_attribute
@@ -307,10 +311,10 @@
 
 local color_node = function (node, color)
   local attr = oberdiek.luacolor.getattribute()
-  if node.id == DISC then
+  if node and node.id == DISC then
      local pre = node.pre
      local post = node.post
-     local replace = node.replace
+     local repl = node.replace
      if pre then
         set_attribute(pre,attr,color)
      end
@@ -317,10 +321,10 @@
      if post then
         set_attribute(post,attr,color)
      end
-     if replace then
-        set_attribute(replace,attr,color)
+     if repl then
+        set_attribute(repl,attr,color)
      end
-  else
+  elseif node then
      set_attribute(node,attr,color)
   end
 end
@@ -333,7 +337,7 @@
 local color_line = function (head, color)
   local first = head.head
   for n in traverse(first) do
-      if n.id == HLIST and n.subtype == BOX then
+      if n and n.id == HLIST and n.subtype == BOX then
          color_hbox(n, color)
       else
          color_node(n, color)
@@ -343,7 +347,7 @@
 local signature = function (node, string, swap)
   local n = node
   local str = string
-  if n.id == GLYPH then
+  if n and n.id == GLYPH then
     local b, id = is_glyph(n)
     if b and not char_to_discard[b] then
        if b == 0x2019 then b = 0x27 end
@@ -355,9 +359,15 @@
              c = string.reverse(c)
           end
           str = str .. c
+       elseif n.subtype == LIGA and b > 0xE000 then
+          local c = string.sub(b,-2)
+          if swap then
+             c = string.reverse(c)
+          end
+          str = str .. c
        end
     end
-  elseif n.id == DISC then
+  elseif n and n.id == DISC then
     local pre = n.pre
     local post = n.post
     local c1 = ""
@@ -376,36 +386,38 @@
        end
     end
     if swap then
-       str = str .. c2  .. c1
+       str = str .. c2 .. c1
     else
        str = str .. c1 .. c2
     end
   end
   local len = string.len(str)
+  if string.find(str, "_") then
+     len = len - 1
+  end
   return len, str
 end
 local check_last_word = function (old, node, color, flag)
   local match = false
   local new = ""
-  local len = 0
-  if flag then
+  local maxlen = 0
+  if flag and node then
      local swap = true
      local lastn = node
-     while lastn and lastn.id ~= GLYPH and lastn.prev do
+     while lastn and lastn.id ~= GLYPH and lastn.id ~= DISC do
        lastn = lastn.prev
      end
      local n = lastn
-     repeat
-       len, new = signature (n, new, swap)
+     while n and n.id ~= GLUE do
+       maxlen, new = signature (n, new, swap)
        n = n.prev
-     until not n or n.id == GLUE
+     end
      if n and n.id == GLUE then
         new = new .. "_"
-        len = len + 1
         repeat
           n = n.prev
-          len, new = signature (n, new, swap)
-        until n.id == GLUE or not n.prev
+          maxlen, new = signature (n, new, swap)
+        until not n or n.id == GLUE
      end
      new = string.reverse(new)
      local MinFull = luatypo.MinFull
@@ -412,27 +424,27 @@
      local MinPart = luatypo.MinPart
      MinFull = math.min(MinPart,MinFull)
      local k = MinPart
-     local oldlast = string.gsub (old, '%w+_', '')
-     local newlast = string.gsub (new, '%w+_', '')
-     len = string.len(newlast)
-     if len < MinPart then
+     local oldlast = string.gsub (old, '.*_', '')
+     local newlast = string.gsub (new, '.*_', '')
+     local i = string.find(new, "_")
+     if i and i > maxlen - MinPart + 1 then
         k = MinPart + 1
      end
      local oldsub = string.sub(old,-k)
      local newsub = string.sub(new,-k)
-     local maxlen = string.len(new)
-     if oldsub == newsub then
+     local l = string.len(new)
+     if oldsub == newsub and l >= k then
         match = true
-     elseif oldlast == newlast and len >= MinFull then
+     elseif oldlast == newlast and string.len(newlast) >= MinFull then
         match = true
         oldsub = oldlast
         newsub = newlast
-        k = len
+        k = string.len(newlast)
      end
      if match then
         local osub = oldsub
         local nsub = newsub
-        while osub == nsub and k < maxlen do
+        while osub == nsub and k <= maxlen do
           k = k +1
           osub = string.sub(old,-k)
           nsub = string.sub(new,-k)
@@ -440,20 +452,19 @@
              newsub = nsub
           end
         end
+        newsub = string.gsub(newsub, '^_', '')
         oldsub = string.reverse(newsub)
         local newsub = ""
-        local k = string.len(oldsub)
         local n = lastn
         repeat
           if n and n.id ~= GLUE then
              color_node(n, color)
-             len, newsub = signature(n, newsub, swap)
+             l, newsub = signature(n, newsub, swap)
           elseif n then
              newsub = newsub .. "_"
-             len = len + 1
           end
           n = n.prev
-        until not n or newsub == oldsub or len >= k
+        until not n or newsub == oldsub or l >= k
      end
   end
   return new, match
@@ -462,49 +473,51 @@
   local match = false
   local swap = false
   local new = ""
-  local len = 0
+  local maxlen = 0
   local start = node
   local n = start
-  while n and n.id ~= GLUE do
-    len, new = signature (n, new, swap)
-    n = n.next
+  while n and n.id ~= GLYPH and n.id ~= DISC do
+     n = n.next
   end
-  n = n.next
-  new = new .. "_"
   while n and n.id ~= GLUE do
-    len, new = signature (n, new, swap)
+    maxlen, new = signature (n, new, swap)
     n = n.next
   end
+  if n and n.id == GLUE then
+     new = new .. "_"
+     repeat
+       n = n.next
+       maxlen, new = signature (n, new, swap)
+     until not n or n.id == GLUE
+  end
   if flag then
      local MinFull = luatypo.MinFull
      local MinPart = luatypo.MinPart
      MinFull = math.min(MinPart,MinFull)
      local k = MinPart
-     local L = MinPart -1
      local oldsub = ""
      local newsub = ""
-     local oldfirst = string.gsub (old, '_%w+', '')
-     local newfirst = string.gsub (new, '_%w+', '')
-     len = string.len(newfirst)
-     if len < MinPart then
+     local oldfirst = string.gsub (old, '_.*', '')
+     local newfirst = string.gsub (new, '_.*', '')
+     local i = string.find(new, "_")
+     if i and i <= MinPart then
         k = MinPart + 1
      end
-     local maxlen = string.len(new)
-     local oldsub = string.sub(old,1,L)
-     local newsub = string.sub(new,1,L)
-     if oldsub == newsub then
+     local oldsub = string.sub(old,1,k)
+     local newsub = string.sub(new,1,k)
+     local l = string.len(newsub)
+     if oldsub == newsub and l >= k then
         match = true
-        k = L
-     elseif oldfirst == newfirst  and len >= MinFull then
+     elseif oldfirst == newfirst  and string.len(newfirst) >= MinFull then
         match = true
         oldsub = oldfirst
         newsub = newfirst
-        k = len
+        k = string.len(newfirst)
      end
      if match then
         local osub = oldsub
         local nsub = newsub
-        while osub == nsub and k < maxlen do
+        while osub == nsub and k <= maxlen do
           k = k + 1
           osub = string.sub(old,1,k)
           nsub = string.sub(new,1,k)
@@ -512,11 +525,7 @@
              newsub = nsub
           end
         end
-        if k < MinPart then
-           match =false
-        end
-     end
-     if match then
+        newsub = string.gsub(newsub, '_$', '')   --$
         oldsub = newsub
         local newsub = ""
         local k = string.len(oldsub)
@@ -524,13 +533,12 @@
         repeat
           if n and n.id ~= GLUE then
              color_node(n, color)
-             len, newsub = signature(n, newsub, swap)
+             l, newsub = signature(n, newsub, swap)
           elseif n then
              newsub = newsub .. "_"
-             len = len + 1
           end
           n = n.next
-        until not n or newsub == oldsub or len >= k
+        until not n or newsub == oldsub or l >= k
      end
   end
   return new, match
@@ -581,7 +589,7 @@
 end
 local show_pre_disc = function (disc, color)
   local n = disc
-  while n.id ~= GLUE do
+  while n and n.id ~= GLUE do
     color_node(n, color)
     n = n.prev
   end
@@ -623,13 +631,16 @@
        pprevnode = prevnode.prev
     end
     if head.id == GLUE and head.subtype == TOPSKIP then
-       pageflag = false
-       match1 = false
        pageno = tex.getcount("c at page")
        hyphcount = 0
-       pagelines = 0
-       firstwd = ""
-       lastwd = ""
+       if pageno > prevno then
+          pageflag = false
+          pagelines = 0
+          match1 = false
+          firstwd = ""
+          lastwd = ""
+          prevno = pageno
+       end
     elseif head.id == HLIST and head.subtype == LINE then
        local first = head.head
        if first.id == MKERN or
@@ -638,15 +649,19 @@
        end
        pagelines = pagelines + 1
        local ListItem = false
-       local textline = true
-       local n = first
-       while (n and n.id ~= GLYPH) and
-             not (n.id == GLUE and n.subtype == RGTSKIP) do
-         n = n.next
+       local textline = false
+       if first.id == GLYPH then
+          textline = true
+       else
+          local n = first
+          repeat
+            n = n.next
+            if n and n.id == GLYPH then
+               textline = true
+               break
+            end
+          until not n or (n.id == GLUE and n.subtype == RGTSKIP)
        end
-       if n.id == GLUE then
-          textline = false
-       end
        if head.glue_set == 1 and head.glue_sign == 2 and
           head.glue_order == 0 and OverfullLines then
           pageflag = true
@@ -786,9 +801,9 @@
           color_line (head, COLOR)
        end
        if lwhyphflag and EOPHyphens then
+          pageflag = true
           local COLOR = luatypo.colortbl[1]
           local pg = show_pre_disc (pn,COLOR)
-          pageflag = true
        end
     elseif not nextnode and head.id == GLUE and
                             head.subtype == USRSKIP then
@@ -795,17 +810,23 @@
        if pagelines > 1 and pagelines < PAGEmin and ShortPages then
           pageflag = true
           local COLOR = luatypo.colortbl[9]
-          local node = head
-          while node.id ~= HLIST or node.subtype ~= LINE do
-             node = node.prev
+          local n = head
+          while n and (n.id ~= HLIST or n.subtype ~= LINE) do
+             n = n.prev
           end
-          color_line(node, COLOR)
+          if n then
+             color_line(n, COLOR)
+          end
        end
     end
   head = nextnode
   end
   if pageflag then
-     luatypo.pagelist = luatypo.pagelist .. tostring(pageno) .. ", "
+     local pl = luatypo.pagelist
+     local p = tonumber(string.match(pl, "%s(%d+),%s$"))
+     if not p or pageno > p then
+        luatypo.pagelist = luatypo.pagelist .. tostring(pageno) .. ", "
+     end
   end
   return true
 end



More information about the tex-live-commits mailing list.