summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/lua-typo/source/lua-typo.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/latex/lua-typo/source/lua-typo.dtx')
-rw-r--r--macros/luatex/latex/lua-typo/source/lua-typo.dtx121
1 files changed, 80 insertions, 41 deletions
diff --git a/macros/luatex/latex/lua-typo/source/lua-typo.dtx b/macros/luatex/latex/lua-typo/source/lua-typo.dtx
index 7809a01377..0fdb2395f8 100644
--- a/macros/luatex/latex/lua-typo/source/lua-typo.dtx
+++ b/macros/luatex/latex/lua-typo/source/lua-typo.dtx
@@ -12,7 +12,7 @@
%
% Lua-Typo package for LaTeX version 2e
%
-% Copyright © 2020-2023 by Daniel Flipo
+% Copyright © 2020-2024 by Daniel Flipo
%
% Please report errors to: daniel (dot) flipo (at) free (dot) fr
%
@@ -166,11 +166,15 @@
% ne va pas provoquer d’autres désordres bien plus graves.\\
% b) Inversement, il n’est pas exclu que \pkg{lua-typo} comporte
% des bogues l’empêchant de détecter des lignes potentiellement
-% imparfaites.
+% imparfaites. Depuis la version~0.85, le fichier \file{.typo}
+% fournit, s’il y a lieu, une liste de pages « suspectes », celles où
+% aucune ligne de texte n’a été trouvée. L’avertissement peut être
+% anodin (page contenant uniquement des illustrations par exemple) ou
+% révéler un défaut de détection.
%
% \pkg{lua-typo} est largement configurable et devrait pouvoir
-% s’adapter aux exigences variables des auteurs ou correcteurs : voir
-% ci-dessous la liste des options et le fichier de configuration
+% s’adapter aux exigences variables des auteurs ou correcteurs :
+% voir ci-dessous la liste des options et le fichier de configuration
% \file{lua-typo.cfg}.
%
% \pkg{lua-typo} ne corrigeant aucun des « défauts » relevés, quels
@@ -489,7 +493,10 @@
% Moreover, correcting a potential issue somewhere may result in
% other much more serious flaws somewhere else …\\
% b) Conversely, possible bugs in \pkg{lua-typo} might hide issues
-% that should normally be highlighted.
+% that should normally be highlighted. Starting with version~0.85,
+% the \file{<jobname>.typo} file lists, if any, the pages on which
+% no text line could be found. The warning may be irrelevant (page
+% only composed of figures) or point out a possible bug.
%
% \pkg{lua-typo} is highly configurable in order to meet the
% variable expectations of authors and correctors: see the options’
@@ -579,12 +586,12 @@
% please note that \opt{All} has to be the first one, as options are
% taken into account as they are read \emph{i.e.} from left to right.
%
+% \newpage
% The list of all available options is printed to the \file{.log}
% file when option \opt{ShowOptions} is passed to \pkg{lua-typo},
% this option provides an easy way to get their names without having
% to look into the documentation.
%
-% \newpage
% With option \opt{None}, \pkg{lua-typo} \emph{does absolutely
% nothing}, all checks are disabled as the main function is not added
% to any LuaTeX callback. It not quite equivalent to commenting out
@@ -745,7 +752,7 @@
%<+scan>\ProvidesPackage{scan-page}
%<+dtx>\ProvidesFile{lua-typo.dtx}
%<*dtx|sty|scan>
- [2023-09-13 v.0.85 Daniel Flipo]
+ [2024-01-12 v.0.86 Daniel Flipo]
%</dtx|sty|scan>
%<*sty>
% \fi
@@ -1426,6 +1433,8 @@ end
% \changes{v0.65}{2023/03/02}{All ligatures are now split using the
% node’s `components’ field rather than a table.}
%
+% \changes{v0.86}{2024/01/10}{Typo corrected in the signature function.}
+%
% The first function adds a (non-nil) node to a signature of type
% string, nil nodes are ignored.
% It returns the augmented string and its length
@@ -1469,7 +1478,7 @@ local signature = function (node, string, swap)
local c2 = ""
if pre and pre.char then
if pre.components then
- for nn in traverse_id(GLYPH, post.components) do
+ for nn in traverse_id(GLYPH, pre.components) do
c1 = c1 .. utf8.char(nn.char)
end
else
@@ -2174,11 +2183,14 @@ end
% \changes{v0.50}{2021/05/02}{New function `get\_pagebody’ required for
% callback `pre\_shipout\_filter’.}
%
+% \changes{v0.86}{2024/01/10}{Package `stfloats’ adds 1sp to the
+% external \cs{vbox}. Be less picky regarding height test.}
+%
% \begin{macrocode}
local get_pagebody = function (head)
local textht = tex.getdimen("textheight")
local fn = head.list
- local body = nil
+ local body
repeat
fn = fn.next
until fn.id == VLIST and fn.height > 0
@@ -2189,9 +2201,17 @@ local get_pagebody = function (head)
%<dbg> texio.write(' ht=' .. ht .. ' dp=' .. dp)
first = fn.list
for n in traverse_id(VLIST,first) do
- if n.subtype == 0 and n.height == textht then
+% \end{macrocode}
+% Package `stfloats’ seems to add 1sp to the external \cs{vbox}
+% for each float found on the page.
+% Add $\pm8$sp tolerance when comparing |n.height| to
+% |\textheight|.
+% \begin{macrocode}
+ if n.subtype == 0 and n.height >= textht-1 and
+ n.height <= textht+8 then
%<dbg> local ht = string.format("%.1fpt", n.height/65536)
%<dbg> texio.write_nl('BODY found: ht=' .. ht)
+%<dbg> texio.write_nl(', ' .. n.height .. 'sp')
%<dbg> texio.write_nl(' ')
body = n
break
@@ -2199,13 +2219,17 @@ local get_pagebody = function (head)
%<dbg> texio.write_nl('Skip short VLIST:')
%<dbg> local ht = string.format("%.1fpt", n.height/65536)
%<dbg> local dp = string.format("%.1fpt", n.depth/65536)
-%<dbg> texio.write(' ht=' .. ht .. ' dp=' .. dp)
- first = n.list
- for n in traverse_id(VLIST,first) do
- if n.subtype == 0 and n.height == textht then
-%<dbg> local ht = string.format("%.1fpt", n.height/65536)
-%<dbg> texio.write_nl(' BODY: ht=' .. ht)
- body = n
+%<dbg> texio.write('ht=' .. ht .. ', ' .. n.height .. 'sp')
+%<dbg> texio.write('; dp=' .. dp)
+ local ff = n.list
+ for nn in traverse_id(VLIST,ff) do
+%<dbg> ht = string.format("%.1fpt", nn.height/65536)
+%<dbg> texio.write_nl(' VLIST: ht=' .. ht)
+%<dbg> texio.write(', ' .. nn.height .. 'sp')
+ if nn.subtype == 0 and nn.height >= textht-1 and
+ nn.height <= textht+8 then
+%<dbg> texio.write(' got BODY!')
+ body = nn
break
end
end
@@ -2697,7 +2721,7 @@ check_vtop = function (top, colno, vpos)
% \begin{macrocode}
page_bottom, body_bottom = check_EOP (nextnode)
% \end{macrocode}
-% Let’s check for an ``Overfull box’’. For a displayed equation
+% Let’s check for an `Overfull box’. For a displayed equation
% it is straightforward. A set of aligned equations all have the
% same (maximal) width; in order to avoid highlighting the whole
% set, we have to look for glues at the end of embedded
@@ -2855,22 +2879,25 @@ end
%
% \begin{macrocode}
luatypo.check_page = function (head)
- local textwd = tex.getdimen("textwidth")
- local textht = tex.getdimen("textheight")
- local checked, boxed, n2, n3, col, colno
- local body = get_pagebody(head)
local pageno = tex.getcount("c@page")
+ local body = get_pagebody(head)
+ local textwd, textht, checked, boxed
+ local top, first, next
+ local n2, n3, col, colno
local vpos = 0
local footnote = false
- local top = body
- local first = body.list
- local next
local count = 0
-%<dbg> texio.write_nl('Body=' .. tostring(node.type(top.id)))
-%<dbg> texio.write('-' .. tostring(top.subtype))
-%<dbg> texio.write('; First=' .. tostring(node.type(first.id)))
-%<dbg> texio.write('-' .. tostring(first.subtype))
-%<dbg> texio.write_nl(' ')
+ if body then
+ top = body
+ first = body.list
+ textwd = tex.getdimen("textwidth")
+ textht = tex.getdimen("textheight")
+%<dbg> texio.write_nl('Body=' .. tostring(node.type(top.id)))
+%<dbg> texio.write('-' .. tostring(top.subtype))
+%<dbg> texio.write('; First=' .. tostring(node.type(first.id)))
+%<dbg> texio.write('-' .. tostring(first.subtype))
+%<dbg> texio.write_nl(' ')
+ end
if ((first and first.id == HLIST and first.subtype == BOX) or
(first and first.id == VLIST and first.subtype == 0)) and
(first.width == textwd and first.height > 0 and not boxed) then
@@ -2880,12 +2907,13 @@ luatypo.check_page = function (head)
% \begin{macrocode}
%<dbg> local boxwd = string.format("%.1fpt", first.width/65536)
%<dbg> texio.write_nl('One step down: boxwd=' .. boxwd)
+%<dbg> texio.write_nl('Glue order=' .. tostring(first.glue_order))
%<dbg> texio.write_nl(' ')
top = body.list
% \end{macrocode}
% A float on top of a page is a VLIST-0 included in a VLIST-0 (body),
% it should not trigger this step down. Workaround: the body will be
-% read again.
+% scanned again.
% \begin{macrocode}
if first.id == VLIST then
boxed = body
@@ -3131,8 +3159,9 @@ return luatypo.check_page
%% Language specific settings (example for French):
%% short words (two letters max) to be avoided at end of lines.
-%%\luatypoOneChar{french}{"À Ô Y"}
-%%\luatypoTwoChars{french}{"Je Tu Il On Au De"}
+%%\luatypoOneChar{french}{"A À Ô Y"}
+%%\luatypoTwoChars{french}{"Ah Au Ça Çà Ce De Il Je La Là Le Ma Me Ne Ni
+%% Oh On Or Ou Où Sa Se Si Ta Tu Va Vu"}
% \end{macrocode}
%
% \iffalse
@@ -3258,7 +3287,7 @@ local is_glyph = node.is_glyph
local get_pagebody = function (head)
local textht = tex.getdimen("textheight")
local fn = head.list
- local body = nil
+ local body
repeat
fn = fn.next
until fn.id == VLIST and fn.height > 0
@@ -3267,9 +3296,11 @@ local get_pagebody = function (head)
local dp = string.format("%.1fpt", fn.depth/65536)
texio.write_nl("SKIP vlist: ht=" .. ht .. " dp=" .. dp)
for n in traverse_id(VLIST,first) do
- if n.subtype == 0 and n.height == textht then
+ if n.subtype == 0 and n.height >= textht-1 and
+ n.height <= textht+8 then
local ht = string.format("%.1fpt", n.height/65536)
- texio.write_nl(' BODY: ' .. ht)
+ texio.write_nl(' BODY found: ' .. ht)
+ texio.write(', ' .. n.height .. 'sp')
texio.write_nl(' ')
body = n
break
@@ -3277,13 +3308,15 @@ local get_pagebody = function (head)
local ht = string.format("%.1fpt", n.height/65536)
local dp = string.format("%.1fpt", n.depth/65536)
texio.write_nl(' SKIP vlist: ht=' .. ht .. ' dp=' .. dp)
- first = n.list
- for n in traverse_id(VLIST,first) do
- if n.subtype == 0 and n.height == textht then
- ht = string.format("%.1fpt", n.height/65536)
+ local ff = n.list
+ for nn in traverse_id(VLIST,ff) do
+ if nn.subtype == 0 and nn.height >= textht-1 and
+ nn.height <= textht+8 then
+ ht = string.format("%.1fpt", nn.height/65536)
texio.write_nl(' BODY: ' .. ht)
+ texio.write(', ' .. nn.height .. 'sp')
texio.write_nl(' ')
- body = n
+ body = nn
break
end
end
@@ -3360,6 +3393,12 @@ local scanvlist = function (head)
texio.write(tostring(node.type(body.id)))
texio.write('-')
texio.write(tostring(body.subtype))
+ else
+ texio.write_nl('Function get_pagebody returned NIL!')
+ texio.write_nl('=> Scanning whole page: node type ')
+ texio.write(tostring(node.type(head.id)))
+ texio.write('-')
+ texio.write(tostring(head.subtype))
end
while head do
texio.write_nl(tostring(node.type(head.id)))