summaryrefslogtreecommitdiff
path: root/macros/luatex/latex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-04-30 03:01:09 +0000
committerNorbert Preining <norbert@preining.info>2023-04-30 03:01:09 +0000
commit7932c8102a8f5298d7d36caa6df233c356f96e56 (patch)
tree29f63548f8a9aded2b185da657ef12a769870028 /macros/luatex/latex
parent76a6fd547d47614b546d7e566bae544de7b88efc (diff)
CTAN sync 202304300301
Diffstat (limited to 'macros/luatex/latex')
-rw-r--r--macros/luatex/latex/lua-typo/README.md10
-rw-r--r--macros/luatex/latex/lua-typo/doc/lua-typo-demo.pdfbin16859 -> 16859 bytes
-rw-r--r--macros/luatex/latex/lua-typo/doc/lua-typo-fr.pdfbin106400 -> 106625 bytes
-rw-r--r--macros/luatex/latex/lua-typo/doc/lua-typo.pdfbin205259 -> 208526 bytes
-rw-r--r--macros/luatex/latex/lua-typo/lua-typo-2023-03-08.sty14
-rw-r--r--macros/luatex/latex/lua-typo/source/lua-typo.dtx561
6 files changed, 319 insertions, 266 deletions
diff --git a/macros/luatex/latex/lua-typo/README.md b/macros/luatex/latex/lua-typo/README.md
index 82c1c9b0c4..526538afb0 100644
--- a/macros/luatex/latex/lua-typo/README.md
+++ b/macros/luatex/latex/lua-typo/README.md
@@ -91,7 +91,15 @@ Changes
* v.0.70:
- Options handled via `ltkeys` instead of `kvoptions`.
- code cleaning, bug fixes.
+
+* v.0.80:
+ - Config file `lua-typo.cfg` changed (new colours added, all colour
+ numbers are shifted by 1).
+ - Colours no longer override each other, a special colour has been
+ added for lines affected by multiple flaws (f.i. widow+overfull).
+ - Bug fix (file `.typo`): in footnotes, line numbers for homeoarchy
+ were not reset.
--
-Copyright 2020--2023 Daniel Flipo
+Copyright 2020--2023 Daniel Flipo
E-mail: daniel (dot) flipo (at) free (dot) fr
diff --git a/macros/luatex/latex/lua-typo/doc/lua-typo-demo.pdf b/macros/luatex/latex/lua-typo/doc/lua-typo-demo.pdf
index a7b1d9a40f..6606b65d36 100644
--- a/macros/luatex/latex/lua-typo/doc/lua-typo-demo.pdf
+++ b/macros/luatex/latex/lua-typo/doc/lua-typo-demo.pdf
Binary files differ
diff --git a/macros/luatex/latex/lua-typo/doc/lua-typo-fr.pdf b/macros/luatex/latex/lua-typo/doc/lua-typo-fr.pdf
index cd64bdaf45..88dea3e4de 100644
--- a/macros/luatex/latex/lua-typo/doc/lua-typo-fr.pdf
+++ b/macros/luatex/latex/lua-typo/doc/lua-typo-fr.pdf
Binary files differ
diff --git a/macros/luatex/latex/lua-typo/doc/lua-typo.pdf b/macros/luatex/latex/lua-typo/doc/lua-typo.pdf
index 537414c80d..b43a1f75fe 100644
--- a/macros/luatex/latex/lua-typo/doc/lua-typo.pdf
+++ b/macros/luatex/latex/lua-typo/doc/lua-typo.pdf
Binary files differ
diff --git a/macros/luatex/latex/lua-typo/lua-typo-2023-03-08.sty b/macros/luatex/latex/lua-typo/lua-typo-2023-03-08.sty
index aa876b82fa..1545689b84 100644
--- a/macros/luatex/latex/lua-typo/lua-typo-2023-03-08.sty
+++ b/macros/luatex/latex/lua-typo/lua-typo-2023-03-08.sty
@@ -5,23 +5,13 @@
%% The original source files were:
%%
%% lua-typo.dtx (with options: `sty')
-%%
+%%
%% IMPORTANT NOTICE:
%% For the copyright see the source file `lua-typo.dtx’.
%%
\NeedsTeXFormat{LaTeX2e}[2021/06/01]
\ProvidesPackage{lua-typo}
[2023-03-08 v.0.65 Daniel Flipo]
-\ifdefined\DeclareRelease
- \DeclareRelease{v0.4}{2021-01-01}{lua-typo-2021-04-18.sty}
- \DeclareCurrentRelease{}{2023-03-08}
-\else
- \PackageWarning{lua-typo}{Your LaTeX kernel is too old to provide
- access\MessageBreak to former versions of the lua-typo package.%
- \MessageBreak Anyway, lua-typo requires a LaTeX kernel dated%
- \MessageBreak 2020-01-01 or newer; reported}
-\fi
-\NeedsTeXFormat{LaTeX2e}[2021/06/01]
\ifdefined\directlua
\RequirePackage{luatexbase,luacode,luacolor}
\RequirePackage{kvoptions,atveryend}
@@ -1340,6 +1330,6 @@ return luatypo.check_page
\luatypoMinPART=4\relax
\luatypoMinLen=4\relax
}%
-%%
+%%
%%
%% End of file `lua-typo.sty'.
diff --git a/macros/luatex/latex/lua-typo/source/lua-typo.dtx b/macros/luatex/latex/lua-typo/source/lua-typo.dtx
index dfcc363cd4..4ec480c921 100644
--- a/macros/luatex/latex/lua-typo/source/lua-typo.dtx
+++ b/macros/luatex/latex/lua-typo/source/lua-typo.dtx
@@ -204,12 +204,13 @@
% \pkg{lua-typo}, il suffit d’ajouter dans le préambule la ligne %\\
% |\usepackage[All]{lua-typo}|
%
-% La version courante (0.65) nécessite un noyau LaTeX récent,
-% 2021/06/01 ou ultérieur. Ceux qui ne disposent que d’un noyau plus
-% ancient reçoivent un message d’avertissement et un message d’erreur
+% La version courante (0.80) nécessite un noyau LaTeX récent,
+% 2022/06/01 ou ultérieur. Ceux qui ne disposent que d’un noyau
+% antérieur à 2021/06/01 reçoivent un message d’erreur
% «\texttt{Unable to register callback}» ; une version «rollback »
% est prévue à leur intention, elle se charge par la commande
-% |\usepackage[All]{lua-typo}[=v0.4]|.
+% |\usepackage[All]{lua-typo}[=v0.4]|. Une autre version
+% intermédiaire est présente, elle se charge avec l’option |[=v0.65]|.
%
% Les fichiers \file{demo.tex} et \file{demo.pdf} fournissent un
% exemple du traitement opéré par \pkg{lua-typo}.
@@ -409,26 +410,28 @@
% À chacune des vérifications faites par \pkg{lua-typo} peut être
% attachée une couleur spécifique pour mettre en évidence les
% imperfections détectées.
-% Actuellement, seulement cinq couleurs sont utilisées par défaut,
+% Actuellement, seulement six couleurs sont utilisées par défaut,
% voici leur définition dans \file{lua-typo.cfg} :
% \begin{verbatim}
% \definecolor{LTgrey}{gray}{0.6}
% \definecolor{LTred}{rgb}{1,0.55,0}
-% \luatypoSetColor0{red} % Coupure à l’avant-dernière ligne
-% \luatypoSetColor1{red} % Coupure en bas de page
-% \luatypoSetColor2{red} % Coupures consécutives
-% \luatypoSetColor3{red} % Mot court en fin de ligne
-% \luatypoSetColor4{cyan} % Veuve
-% \luatypoSetColor5{cyan} % Orpheline
-% \luatypoSetColor6{cyan} % Dernière ligne d’alinéa trop courte
-% \luatypoSetColor7{blue} % Ligne trop pleine
-% \luatypoSetColor8{blue} % Ligne creuse
-% \luatypoSetColor9{red} % Page presque vide (qq. lignes)
-% \luatypoSetColor{10}{LTred} % Répétitions en début de ligne
-% \luatypoSetColor{11}{LTred} % Répétitions en fin de ligne
-% \luatypoSetColor{12}{LTgrey}% Dernière ligne alinéa presque pleine
-% \luatypoSetColor{13}{cyan} % Note de bas de page éclatée
-% \luatypoSetColor{14}{red} % Mot de fin de phrase en haut de page
+% \definecolor{LTline}{rgb}{0.7,0,0.3}
+% \luatypoSetColor1{red} % Coupure à l’avant-dernière ligne
+% \luatypoSetColor2{red} % Coupure en bas de page
+% \luatypoSetColor3{red} % Coupures consécutives
+% \luatypoSetColor4{red} % Mot court en fin de ligne
+% \luatypoSetColor5{cyan} % Veuve
+% \luatypoSetColor6{cyan} % Orpheline
+% \luatypoSetColor7{cyan} % Dernière ligne d’alinéa trop courte
+% \luatypoSetColor8{blue} % Ligne trop pleine
+% \luatypoSetColor9{blue} % Ligne creuse
+% \luatypoSetColor{10}{red} % Page presque vide (qq. lignes)
+% \luatypoSetColor{11}{LTred} % Répétitions en début de ligne
+% \luatypoSetColor{12}{LTred} % Répétitions en fin de ligne
+% \luatypoSetColor{13}{LTgrey}% Dernière ligne alinéa presque pleine
+% \luatypoSetColor{14}{cyan} % Note de bas de page éclatée
+% \luatypoSetColor{15}{red} % Mot de fin de phrase en haut de page
+% \luatypoSetColor{16}{LTline}% Ligne présentant plusieurs "défauts"
% \end{verbatim}
% \pkg{lua-typo} charge les extensions \pkg{luacolor} et donc
% \pkg{color}. Seules les couleurs portant un nom (\emph{named
@@ -504,11 +507,15 @@
% the final document would be a shame!
%
% Starting with version 0.50 a recent LaTeX kernel (dated 2021/06/01)
-% is reiquired. Users running an older kernel will get a warning
+% is required. Users running an older kernel will get a warning
% and an error message ``\texttt{Unable to register callback}’’;
% for them, a ``rollback’’ version of \pkg{lua-typo} is provided,
% it can be loaded this way: |\usepackage[All]{lua-typo}[=v0.4]|.
%
+% Version 0.80 requires a LaTeX kernel dated 2022/06/01 or later.
+% Another ``rollback’’ version |[=v0.65]| has been added for those
+% who run an older kernel.
+%
% See files \file{demo.tex} and \file{demo.pdf} for a short example
% (in French).
%
@@ -679,26 +686,27 @@
%
% It is possible to define a specific colour for each
% typographic flaws that \pkg{lua-typo} deals with.
-% Currently, only five colours are used in \file{lua-typo.cfg}:
+% Currently, only six colours are used in \file{lua-typo.cfg}:
% \begin{verbatim}
% \definecolor{LTgrey}{gray}{0.6}
% \definecolor{LTred}{rgb}{1,0.55,0}
-% \luatypoSetColor0{red} % Paragraph last full line hyphenated
-% \luatypoSetColor1{red} % Page last word hyphenated
-% \luatypoSetColor2{red} % Hyphens on consecutive lines
-% \luatypoSetColor3{red} % Short word at end of line
-% \luatypoSetColor4{cyan} % Widow
-% \luatypoSetColor5{cyan} % Orphan
-% \luatypoSetColor6{cyan} % Paragraph ending on a short line
-% \luatypoSetColor7{blue} % Overfull lines
-% \luatypoSetColor8{blue} % Underfull lines
-% \luatypoSetColor9{red} % Nearly empty page (a few lines)
-% \luatypoSetColor{10}{LTred} % First word matches
-% \luatypoSetColor{11}{LTred} % Last word matches
-% \luatypoSetColor{12}{LTgrey}% Paragraph’s last line nearly full
-% \luatypoSetColor{13}{cyan} % Footnotes spread over two pages
-% \luatypoSetColor{14}{red} % Short final word on top of the page
-% \end{verbatim}
+% \definecolor{LTline}{rgb}{0.7,0,0.3}
+% \luatypoSetColor1{red} % Paragraph last full line hyphenated
+% \luatypoSetColor2{red} % Page last word hyphenated
+% \luatypoSetColor3{red} % Hyphens on consecutive lines
+% \luatypoSetColor4{red} % Short word at end of line
+% \luatypoSetColor5{cyan} % Widow
+% \luatypoSetColor6{cyan} % Orphan
+% \luatypoSetColor7{cyan} % Paragraph ending on a short line
+% \luatypoSetColor8{blue} % Overfull lines
+% \luatypoSetColor9{blue} % Underfull lines
+% \luatypoSetColor{10}{red} % Nearly empty page (a few lines)
+% \luatypoSetColor{11}{LTred} % First word matches
+% \luatypoSetColor{12}{LTred} % Last word matches
+% \luatypoSetColor{13}{LTgrey}% Paragraph’s last line nearly full
+% \luatypoSetColor{14}{cyan} % Footnotes spread over two pages
+% \luatypoSetColor{15}{red} % Short final word on top of the page
+% \luatypoSetColor{16}{LTline}% Line color for multiple flaws\end{verbatim}
%
% \pkg{lua-typo} loads the \pkg{luacolor} package which loads the
% \pkg{color} package from the LaTeX graphic bundle.
@@ -720,7 +728,7 @@
%<+scan>\ProvidesPackage{scan-page}
%<+dtx>\ProvidesFile{lua-typo.dtx}
%<*dtx|sty|scan>
- [2023-04-12 v.0.70 Daniel Flipo]
+ [2023-04-28 v.0.80 Daniel Flipo]
%</dtx|sty|scan>
%<*sty>
% \fi
@@ -976,6 +984,20 @@ luatypo = { }
luatypo.LLminWD = tex.dimen.luatypoLLminWD
luatypo.BackPI = tex.dimen.luatypoBackPI
luatypo.BackFuzz = tex.dimen.luatypoBackFuzz
+% \end{macrocode}
+% \changes{0.80}{2023/04/28}{New table `luatypo.map’ for colours.}
+%
+% Build a compact table holding all colours defined by
+% \file{lua-typo} (no duplicates).
+% \begin{macrocode}
+ local tbl = luatypo.colortbl
+ local map = { }
+ for i,v in ipairs (luatypo.colortbl) do
+ if i == 1 or v > tbl[i-1] then
+ table.insert(map, v)
+ end
+ end
+ luatypo.map = map
}%
}
% \end{macrocode}
@@ -1071,9 +1093,9 @@ luatypo = { }
% \vspace*{\baselineskip}
% \begin{macro}{\luatypoSetColor}
% This is a user-level command to customise the colours highlighting
-% the fourteen types of possible typographic flaws.
-% The first argument is a number (flaw type), the second the named
-% colour associated to it.
+% the sixteen types of possible typographic flaws.
+% The first argument is a number (flaw type: 1-16), the second the
+% named colour associated to it.
% The colour support is based on the \pkg{luacolor} package (colour
% attributes).
% \begin{macrocode}
@@ -1083,6 +1105,7 @@ luatypo = { }
\directlua{luatypo.colortbl[#1]=\the\LuaCol@Attribute}%
\endgroup
}
+%\luatypoSetColor{0}{black}
% \end{macrocode}
% \end{macro}
%
@@ -1090,11 +1113,12 @@ luatypo = { }
%
% \begin{macrocode}
\begin{luacode}
-luatypo.single = { }
-luatypo.double = { }
-luatypo.colortbl = { }
-luatypo.pagelist = " "
-luatypo.buffer = "List of typographic flaws found for "
+luatypo.colortbl = { }
+luatypo.map = { }
+luatypo.single = { }
+luatypo.double = { }
+luatypo.pagelist = " "
+luatypo.buffer = "List of typographic flaws found for "
.. tex.jobname .. ".pdf:\string\n\string\n"
local char_to_discard = { }
@@ -1161,6 +1185,7 @@ local dimensions = node.dimensions
local rangedimensions = node.rangedimensions
local effective_glue = node.effective_glue
local set_attribute = node.set_attribute
+local get_attribute = node.get_attribute
local slide = node.slide
local traverse = node.traverse
local traverse_id = node.traverse_id
@@ -1240,17 +1265,37 @@ local color_node = function (node, color)
end
% \end{macrocode}
%
-% The nextfunction colours a whole line. It requires two
-% arguments: a line’s node and a (named) colour.\par
+% The next function colours a whole line without overriding
+% previously set colours by f.i.\ homeoarchy, repeated hyphens etc.
+% It requires two arguments: a line’s node and a (named) colour.
+%
% Digging into nested hlists and vlists is needed f.i.\ to colour
% aligned equations.
%
% \changes{v0.50}{2021/05/05}{Go down deeper into hlists and vlists to
% colour nodes.}
%
+% \changes{v0.80}{2023/04/18}{`color\_line’ no longer overwrites colors
+% set previously.}
+%
% \begin{macrocode}
local color_line = function (head, color)
local first = head.head
+ local map = luatypo.map
+ local color_node_if = function (node, color)
+ local c = oberdiek.luacolor.getattribute()
+ local att = get_attribute(node,c)
+ local uncolored = true
+ for i,v in ipairs (map) do
+ if att == v then
+ uncolored = false
+ break
+ end
+ end
+ if uncolored then
+ color_node (node, color)
+ end
+ end
for n in traverse(first) do
if n.id == HLIST or n.id == VLIST then
local ff = n.head
@@ -1267,26 +1312,26 @@ local color_line = function (head, color)
if n5.id == HLIST or n5.id == VLIST then
local f6 = n5.head
for n6 in traverse(f6) do
- color_node(n6, color)
+ color_node_if(n6, color)
end
else
- color_node(n5, color)
+ color_node_if(n5, color)
end
end
else
- color_node(n4, color)
+ color_node_if(n4, color)
end
end
else
- color_node(n3, color)
+ color_node_if(n3, color)
end
end
else
- color_node(nn, color)
+ color_node_if(nn, color)
end
end
else
- color_node(n, color)
+ color_node_if(n, color)
end
end
end
@@ -1428,9 +1473,13 @@ end
% \changes{v0.70}{2023/04/08}{`check\_line\_first\_word’ and
% `check\_line\_last\_word’: length of matches corrected.}
%
+% \changes{v0.80}{2023/04/18}{`check\_line\_first\_word’ and
+% `check\_line\_last\_word’: argument footnote added.}
+%
% \begin{macrocode}
-local check_line_last_word = function (old, node, line, colno, flag)
- local COLOR = luatypo.colortbl[11]
+local check_line_last_word =
+ function (old, node, line, colno, flag, footnote)
+ local COLOR = luatypo.colortbl[12]
local match = false
local new = ""
local maxlen = 0
@@ -1596,8 +1645,9 @@ end
% to set pageflag.}
%
% \begin{macrocode}
-local check_line_first_word = function (old, node, line, colno, flag)
- local COLOR = luatypo.colortbl[10]
+local check_line_first_word =
+ function (old, node, line, colno, flag, footnote)
+ local COLOR = luatypo.colortbl[11]
local match = false
local swap = false
local new = ""
@@ -1729,17 +1779,16 @@ end
%
% \changes{v0.65}{2023/03/02}{New `check\_page\_first\_word’ function.}
%
-% \enlargethispage*{\baselineskip}
-% The next function checks the first word on a new page: if
-% it ends a sentence and is short (up to |\luatypoMinLen| characters),
-% the function returns |true| and colours the offending word.
-% Otherwise it just retrurs |false|.
+% The next function is meant to be called on the first line of a new
+% page. It checks the first word: if it ends a sentence and is short
+% (up to |\luatypoMinLen| characters), the function returns |true|
+% and colours the offending word. Otherwise it just returns |false|.
% The function requires two arguments: the line’s first node and
% a column number (possibly |nil|).
%
% \begin{macrocode}
-local check_page_first_word = function (node, colno)
- local COLOR = luatypo.colortbl[14]
+local check_page_first_word = function (node, colno, footnote)
+ local COLOR = luatypo.colortbl[15]
local match = false
local swap = false
local new = ""
@@ -1771,17 +1820,22 @@ local check_page_first_word = function (node, colno)
n = n.next
end
if len <= minlen and n and n.id == GLYPH and eow_char[n.char] then
- match =true
- if pn and (pn.id == GLUE or pn.id == KERN) then
- new = new .. " "
- len = len + 1
+% \end{macrocode}
+% If the line does not ends here, set |match| to |true| (otherwise
+% this line is just a short line):
+% \begin{macrocode}
+ repeat
+ n = n.next
+ until not n or n.id == GLYPH or
+ (n.id == GLUE and n.subtype == PARFILL)
+ if n and n.id == GLYPH then
+ match = true
end
- len = len + 1
end
%<dbg> texio.write_nl("FinalWord=" .. new)
- if match then
+ if match then
local msg = "ShortFinalWord=" .. new
- log_flaw(msg, 1, colno, false)
+ log_flaw(msg, 1, colno, footnote)
% \end{macrocode}
% Lest’s colour the final word and punctuation sign.
% \begin{macrocode}
@@ -1806,8 +1860,8 @@ end
% to set pageflag in `check\_vtop’.}
%
% \begin{macrocode}
-local check_regexpr = function (glyph, line, colno)
- local COLOR = luatypo.colortbl[3]
+local check_regexpr = function (glyph, line, colno, footnote)
+ local COLOR = luatypo.colortbl[4]
local lang = glyph.lang
local match = false
local retflag = false
@@ -2023,7 +2077,7 @@ end
%
% \begin{macro}{check-vtop}
% The next function is called repeatedly by |check_page| (see below);
-% it scans the boxes found in the page body (f.i. columns)
+% it scans the boxes found in the page body (f.i.\ columns)
% in search of typographical flaws and logs.
%
% \changes{v0.40}{2021/04/18}{Title pages, pages with figures and/or
@@ -2065,14 +2119,18 @@ check_vtop = function (top, colno, vpos)
local vpos_min = PAGEmin * blskip
vpos_min = vpos_min * 1.5
local linewd = tex.getdimen("textwidth")
- local first_bot = true
- local footnote = false
- local ftnsplit = false
+ local first_bot = true
+ local footnote = false
+ local ftnsplit = false
local orphanflag = false
- local widowflag = false
+ local widowflag = false
local pageshort = false
+ local overfull = false
+ local underfull = false
+ local shortline = false
+ local backpar = false
local firstwd = ""
- local lastwd = ""
+ local lastwd = ""
local hyphcount = 0
local pageline = 0
local ftnline = 0
@@ -2114,33 +2172,32 @@ check_vtop = function (top, colno, vpos)
% This has to be known early in order to set the flags |orphanflag|
% and |ftnsplit|.
% \begin{macrocode}
- page_bottom, body_bottom = check_EOP (nextnode)
+ page_bottom, body_bottom = check_EOP(nextnode)
% \end{macrocode}
% Is the current line overfull or underfull?
% \changes{v0.50}{2021/05/13}{Detection of overfull boxes fixed: the
% former code didn’t work for typewriter fonts.}
+% \changes{v0.80}{2023/04/18}{Colouring lines deferred until the full
+% line is scanned.}
% \begin{macrocode}
local hmax = linewd + tex.hfuzz
local w,h,d = dimensions(1,2,0, first)
if w > hmax and OverfullLines then
pageflag = true
+ overfull = true
local wpt = string.format("%.2fpt", (w-head.width)/65536)
local msg = "OVERFULL line " .. wpt
log_flaw(msg, line, colno, footnote)
- 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
pageflag = true
+ underfull = true
local s = string.format("%.0f%s", 100*head.glue_set, "%")
local msg = "UNDERFULL line stretch=" .. s
log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[8]
- color_line (head, COLOR)
end
% \end{macrocode}
-% \enlargethispage*{2\baselineskip}
-% Set flag |ftnsplit| to |true| on every page’s last line.
+% In footnotes, set flag |ftnsplit| to |true| on page’s last line.
% This flag will be reset to false if the current line ends a
% paragraph.
% \begin{macrocode}
@@ -2196,12 +2253,28 @@ check_vtop = function (top, colno, vpos)
parline = parline + 1
end
% \end{macrocode}
-%
-% \changes{v0.61}{2023/02/07}{Tracking of lines beginning with the same
-% word moved further down (colour).}
-%
-% Let’s check the end of line: |ln| (usually a rightskip) and |pn|
-% are the last two nodes.
+% Does the first word and the one on the previous line match
+% (except lists)?
+% \begin{macrocode}
+ if FirstWordMatch then
+ local flag = not ListItem and (line > 1)
+ firstwd, flag =
+ check_line_first_word(firstwd, first, line, colno,
+ flag, footnote)
+ if flag then
+ pageflag = true
+ end
+ end
+% \end{macrocode}
+% Check the page’s first word (end of sentence?).
+% \begin{macrocode}
+ if ShortFinalWord and pageline == 1 and parline > 1 and
+ check_page_first_word(first, colno, footnote) then
+ pageflag = true
+ end
+% \end{macrocode}
+% Let’s now check the end of line: |ln| (usually a rightskip)
+% and |pn| are the last two nodes.
% \begin{macrocode}
local ln = slide(first)
local pn = ln.prev
@@ -2214,10 +2287,9 @@ check_vtop = function (top, colno, vpos)
ftnsplit = false
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. We could colour the whole line right now,
-% but prefer doing it after |ShortLines| and |BackParindent| checks.
-% Orphans will be coloured later in CASE~2 or CASE~3.
+% it is a widow if it is the page’s first line and it does’nt
+% start a new paragraph. If so, we flag this line as `widow’;
+% colouring full lines will take place later.
% \begin{macrocode}
if pageline == 1 and parline > 1 then
widowflag = true
@@ -2237,55 +2309,23 @@ check_vtop = function (top, colno, vpos)
% \begin{macrocode}
if llwd < LLminWD then
pageflag = true
+ shortline = true
local msg = "SHORT LINE: length=" ..
string.format("%.0fpt", llwd/65536)
log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[6]
- local attr = oberdiek.luacolor.getattribute()
-% \end{macrocode}
-% let’s colour the whole line.
-% \begin{macrocode}
- color_line (head, COLOR)
end
end
% \end{macrocode}
% Does this (end of paragraph) line ends too close to the right
-% margin? If so, colour the whole line before checking matching
-% words.
+% margin?
% \begin{macrocode}
if BackParindent and PFskip < BackPI and
PFskip >= BackFuzz and parline > 1 then
pageflag = true
+ backpar = true
local msg = "NEARLY FULL line: backskip=" ..
string.format("%.1fpt", PFskip/65536)
log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[12]
- local attr = oberdiek.luacolor.getattribute()
- color_line (head, COLOR)
- end
-% \end{macrocode}
-% A widow may also be a `SHORT’ or `NEARLY FULL’ line, the widow
-% colour will overright the first two.
-% \begin{macrocode}
- if Widows and widowflag then
- pageflag = true
- local msg = "WIDOW"
- log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[4]
- color_line (head, COLOR)
- widowflag = false
- end
-% \end{macrocode}
-% Does the first word and the one on the previous line match
-% (except lists)?
-% \begin{macrocode}
- if FirstWordMatch then
- local flag = not ListItem and (line > 1)
- firstwd, flag =
- check_line_first_word(firstwd, first, line, colno, flag)
- if flag then
- pageflag = true
- end
end
% \end{macrocode}
% Does the last word and the one on the previous line match?
@@ -2297,7 +2337,8 @@ check_vtop = function (top, colno, vpos)
end
local pnp = pn.prev
lastwd, flag =
- check_line_last_word(lastwd, pnp, line, colno, flag)
+ check_line_last_word(lastwd, pnp, line, colno,
+ flag, footnote)
if flag then
pageflag = true
end
@@ -2307,23 +2348,12 @@ check_vtop = function (top, colno, vpos)
% CASE 2: the current line ends with an hyphen.
% \begin{macrocode}
hyphcount = hyphcount + 1
-% \end{macrocode}
-% Colour the whole line now if it is a orphan or a footnote
-% continuing on the next page.
-% \begin{macrocode}
- if orphanflag and Orphans then
- pageflag = true
- local msg = "ORPHAN"
- log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[5]
- color_line (head, COLOR)
- end
- if ftnsplit and FootnoteSplit then
+ if hyphcount > HYPHmax and RepeatedHyphens then
+ local COLOR = luatypo.colortbl[3]
+ local pg = show_pre_disc (pn,COLOR)
pageflag = true
- local msg = "FOOTNOTE SPLIT"
+ local msg = "REPEATED HYPHENS: more than " .. HYPHmax
log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[13]
- color_line (head, COLOR)
end
if (page_bottom or body_bottom) and EOPHyphens then
% \end{macrocode}
@@ -2333,35 +2363,21 @@ check_vtop = function (top, colno, vpos)
pageflag = true
local msg = "LAST WORD SPLIT"
log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[1]
+ local COLOR = luatypo.colortbl[2]
local pg = show_pre_disc (pn,COLOR)
end
% \end{macrocode}
-% Track matching words at the beginning and end of line.
+% Track matching words at end of line.
% \begin{macrocode}
- if FirstWordMatch then
- local flag = not ListItem
- firstwd, flag =
- check_line_first_word(firstwd, first, line, colno, flag)
- if flag then
- pageflag = true
- end
- end
if LastWordMatch then
local flag = true
lastwd, flag =
- check_line_last_word(lastwd, pn, line, colno, flag)
+ check_line_last_word(lastwd, pn, line, colno,
+ flag, footnote)
if flag then
pageflag = true
end
end
- if hyphcount > HYPHmax and RepeatedHyphens then
- local COLOR = luatypo.colortbl[2]
- local pg = show_pre_disc (pn,COLOR)
- pageflag = true
- local msg = "REPEATED HYPHENS: more than " .. HYPHmax
- log_flaw(msg, line, colno, footnote)
- end
if nextnode and ParLastHyphen then
% \end{macrocode}
% Does the next line end the current paragraph? If so, |nextnode| is
@@ -2377,53 +2393,26 @@ check_vtop = function (top, colno, vpos)
pageflag = true
local msg = "HYPHEN on next to last line"
log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[0]
+ local COLOR = luatypo.colortbl[1]
local pg = show_pre_disc (pn,COLOR)
end
end
end
% \end{macrocode}
% CASE 3: the current line ends with anything else (\node{glyph},
-% \node{mkern}, \node{hlist}, etc.), reset |hyphcount|, colour
-% orphans first, then check for `FirstWordMatch’, `LastWordMatch’
-% and `EOLShortWords’.
+% \node{mkern}, \node{hlist}, etc.), reset |hyphcount|, check for
+% `LastWordMatch’ and `EOLShortWords’.
% \begin{macrocode}
else
hyphcount = 0
% \end{macrocode}
-% Colour the whole line now if it is a orphan or a footnote
-% continuing on the next page.
-% \begin{macrocode}
- if orphanflag and Orphans then
- pageflag = true
- local msg = "ORPHAN"
- log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[5]
- color_line (head, COLOR)
- end
- if ftnsplit and FootnoteSplit then
- pageflag = true
- local msg = "FOOTNOTE SPLIT"
- log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[13]
- color_line (head, COLOR)
- end
-% \end{macrocode}
-% Track matching words at the beginning and end of line and short
-% words.
+% Track matching words at end of line and short words.
% \begin{macrocode}
- if FirstWordMatch then
- local flag = not ListItem
- firstwd, flag =
- check_line_first_word(firstwd, first, line, colno, flag)
- if flag then
- pageflag = true
- end
- end
if LastWordMatch and pn then
local flag = true
lastwd, flag =
- check_line_last_word(lastwd, pn, line, colno, flag)
+ check_line_last_word(lastwd, pn, line, colno,
+ flag, footnote)
if flag then
pageflag = true
end
@@ -2433,22 +2422,69 @@ check_vtop = function (top, colno, vpos)
pn = pn.prev
end
if pn and pn.id == GLYPH then
- if check_regexpr(pn, line, colno) then
+ if check_regexpr(pn, line, colno, footnote) then
pageflag = true
end
end
end
end
% \end{macrocode}
-% Check the page’s first word (end of sentence?).
+% End of scanning for the main type of node (text lines).
+% Let’s colour the whole line if necessary. If more than one kind
+% of flaw \emph{affecting the whole line} has been detected,
+% a special colour is used [homearchy, repeated hyphens, etc.
+% will still be coloured properly: |color_line| doesn’t override
+% previously set colours].
% \begin{macrocode}
- if ShortFinalWord and pageline == 1 and parline > 1 and
- check_page_first_word(first,colno) then
+ if widowflag and Widows then
+ pageflag = true
+ local msg = "WIDOW"
+ log_flaw(msg, line, colno, footnote)
+ local COLOR = luatypo.colortbl[5]
+ if backpar or shortline or overfull or underfull then
+ COLOR = luatypo.colortbl[16]
+ if backpar then backpar = false end
+ if shortline then shortline = false end
+ if overfull then overfull = false end
+ if underfull then underfull = false end
+ end
+ color_line (head, COLOR)
+ widowflag = false
+ elseif orphanflag and Orphans then
+ pageflag = true
+ local msg = "ORPHAN"
+ log_flaw(msg, line, colno, footnote)
+ local COLOR = luatypo.colortbl[6]
+ if overfull or underfull then
+ COLOR = luatypo.colortbl[16]
+ end
+ color_line (head, COLOR)
+ elseif ftnsplit and FootnoteSplit then
pageflag = true
+ local msg = "FOOTNOTE SPLIT"
+ log_flaw(msg, line, colno, footnote)
+ local COLOR = luatypo.colortbl[14]
+ if overfull or underfull then
+ COLOR = luatypo.colortbl[16]
+ end
+ color_line (head, COLOR)
+ elseif shortline then
+ local COLOR = luatypo.colortbl[7]
+ color_line (head, COLOR)
+ shortline = false
+ elseif overfull then
+ local COLOR = luatypo.colortbl[8]
+ color_line (head, COLOR)
+ overfull = false
+ elseif underfull then
+ local COLOR = luatypo.colortbl[9]
+ color_line (head, COLOR)
+ underfull = false
+ elseif backpar then
+ local COLOR = luatypo.colortbl[13]
+ color_line (head, COLOR)
+ backpar = false
end
-% \end{macrocode}
-% End of scanning for the main type of node (text lines).
-% \begin{macrocode}
elseif head.id == HLIST and
(head.subtype == EQN or head.subtype == ALIGN) and
(head.height > 0 or head.depth > 0) then
@@ -2508,7 +2544,7 @@ check_vtop = function (top, colno, vpos)
local wpt = string.format("%.2fpt", w/65536)
local msg = "OVERFULL equation " .. wpt
log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[7]
+ local COLOR = luatypo.colortbl[8]
color_line (head, COLOR)
end
end
@@ -2538,7 +2574,7 @@ check_vtop = function (top, colno, vpos)
% \end{macrocode}
% Track short pages: check the number of lines at end of page,
% in case this number is low, \emph{and} |vpos| is less than
-% |vpos_min|, fetch the last line and colour it.\par
+% |vpos_min|, fetch the last line and colour it.
% \begin{macrocode}
elseif body_bottom and head.id == GLUE and head.subtype == 0 then
if first_bot then
@@ -2554,12 +2590,12 @@ check_vtop = function (top, colno, vpos)
%<dbg> end
%<dbg> texio.write_nl(" ")
if pageline > 1 and pageline < PAGEmin
- and vpos < vpos_min and ShortPages then
+ and vpos < vpos_min and ShortPages then
pageshort = true
pageflag = true
local msg = "SHORT PAGE: only " .. pageline .. " lines"
log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[9]
+ local COLOR = luatypo.colortbl[10]
local n = head
repeat
n = n.prev
@@ -2580,14 +2616,25 @@ check_vtop = function (top, colno, vpos)
vpos = vpos + head.kern
elseif head.id == VLIST then
% \end{macrocode}
-% This is a vertical a |\vbox|, let’s update |vpos|.
+% This is a |\vbox|, let’s update |vpos|.
+% \begin{macrocode}
+ vpos = vpos + head.height + head.depth
+ elseif head.id == HLIST and head.subtype == BOX then
+% \end{macrocode}
+% \changes{v0.80}{2023/04/18}{hlist-2: added detection of page bottom
+% and increment line number and vpos.}
+%
+% This is an |\hbox| (f.i.\ centred), let’s update |vpos|, line
+% and check for page bottom
% \begin{macrocode}
vpos = vpos + head.height + head.depth
+ pageline = pageline + 1
+ line = pageline
+ page_bottom, body_bottom = check_EOP (nextnode)
+ local hf = head.list
% \end{macrocode}
% Leave |check_vtop| if a two columns box starts.
% \begin{macrocode}
- elseif head.id == HLIST and head.subtype == BOX then
- local hf = head.list
if hf and hf.id == VLIST and hf.subtype == 0 then
%<dbg> texio.write_nl("check_vtop: BREAK => multicol")
%<dbg> texio.write_nl(" ")
@@ -2778,21 +2825,23 @@ return luatypo.check_page
\MessageBreak Providing default values.}%
\definecolor{LTgrey}{gray}{0.6}%
\definecolor{LTred}{rgb}{1,0.55,0}
- \luatypoSetColor0{red}% Paragraph last full line hyphenated
- \luatypoSetColor1{red}% Page last word hyphenated
- \luatypoSetColor2{red}% Hyphens on to many consecutive lines
- \luatypoSetColor3{red}% Short word at end of line
- \luatypoSetColor4{cyan}% Widow
- \luatypoSetColor5{cyan}% Orphan
- \luatypoSetColor6{cyan}% Paragraph ending on a short line
- \luatypoSetColor7{blue}% Overfull lines
- \luatypoSetColor8{blue}% Underfull lines
- \luatypoSetColor9{red}% Nearly empty page
- \luatypoSetColor{10}{LTred}% First word matches
- \luatypoSetColor{11}{LTred}% Last word matches
- \luatypoSetColor{12}{LTgrey}% Paragraph ending on a nearly full line
- \luatypoSetColor{13}{cyan}% Footnote split
- \luatypoSetColor{14}{red}% Too short first (final) word on the page
+ \definecolor{LTline}{rgb}{0.7,0,0.3}
+ \luatypoSetColor1{red}% Paragraph last full line hyphenated
+ \luatypoSetColor2{red}% Page last word hyphenated
+ \luatypoSetColor3{red}% Hyphens on to many consecutive lines
+ \luatypoSetColor4{red}% Short word at end of line
+ \luatypoSetColor5{cyan}% Widow
+ \luatypoSetColor6{cyan}% Orphan
+ \luatypoSetColor7{cyan}% Paragraph ending on a short line
+ \luatypoSetColor8{blue}% Overfull lines
+ \luatypoSetColor9{blue}% Underfull lines
+ \luatypoSetColor{10}{red}% Nearly empty page
+ \luatypoSetColor{11}{LTred}% First word matches
+ \luatypoSetColor{12}{LTred}% Last word matches
+ \luatypoSetColor{13}{LTgrey}% Paragraph ending on a nearly full line
+ \luatypoSetColor{14}{cyan}% Footnote split
+ \luatypoSetColor{15}{red}% Too short first (final) word on the page
+ \luatypoSetColor{16}{LTline}% Line color for multiple flaws
\luatypoBackPI=1em\relax
\luatypoBackFuzz=2pt\relax
\ifdim\parindent=0pt \luatypoLLminWD=20pt\relax
@@ -2801,7 +2850,7 @@ return luatypo.check_page
\luatypoHyphMax=2\relax
\luatypoPageMin=5\relax
\luatypoMinFull=3\relax
- \luatypoMinPART=4\relax
+ \luatypoMinPart=4\relax
\luatypoMinLen=4\relax
}%
% \end{macrocode}
@@ -2846,24 +2895,26 @@ return luatypo.check_page
%% a sentence.
\luatypoMinLen=4\relax
-%% Default colours = red, cyan, LTgrey
+%% Default colours = red, cyan, blue, LTgrey, LTred, LTline.
\definecolor{LTgrey}{gray}{0.6}
\definecolor{LTred}{rgb}{1,0.55,0}
-\luatypoSetColor0{red} % Paragraph last full line hyphenated
-\luatypoSetColor1{red} % Page last word hyphenated
-\luatypoSetColor2{red} % Hyphens on to many consecutive lines
-\luatypoSetColor3{red} % Short word at end of line
-\luatypoSetColor4{cyan} % Widow
-\luatypoSetColor5{cyan} % Orphan
-\luatypoSetColor6{cyan} % Paragraph ending on a short line
-\luatypoSetColor7{blue} % Overfull lines
-\luatypoSetColor8{blue} % Underfull lines
-\luatypoSetColor9{red} % Nearly empty page (just a few lines)
-\luatypoSetColor{10}{LTred} % First word matches
-\luatypoSetColor{11}{LTred} % Last word matches
-\luatypoSetColor{12}{LTgrey}% Paragraph ending on a nearly full line
-\luatypoSetColor{13}{cyan} % Footnote split
-\luatypoSetColor{14}{red} % Too short first (final) word on the page
+\definecolor{LTline}{rgb}{0.7,0,0.3}
+\luatypoSetColor1{red}% Paragraph last full line hyphenated
+\luatypoSetColor2{red}% Page last word hyphenated
+\luatypoSetColor3{red}% Hyphens on to many consecutive lines
+\luatypoSetColor4{red}% Short word at end of line
+\luatypoSetColor5{cyan}% Widow
+\luatypoSetColor6{cyan}% Orphan
+\luatypoSetColor7{cyan}% Paragraph ending on a short line
+\luatypoSetColor8{blue}% Overfull lines
+\luatypoSetColor9{blue}% Underfull lines
+\luatypoSetColor{10}{red}% Nearly empty page
+\luatypoSetColor{11}{LTred}% First word matches
+\luatypoSetColor{12}{LTred}% Last word matches
+\luatypoSetColor{13}{LTgrey}% Paragraph ending on a nearly full line
+\luatypoSetColor{14}{cyan}% Footnote split
+\luatypoSetColor{15}{red}% Too short first (final) word on the page
+\luatypoSetColor{16}{LTline}% Line color for multiple flaws
%% Language specific settings (example for French):
%% short words (two letters max) to be avoided at end of lines.
@@ -3035,6 +3086,7 @@ local print_subtype = function (node,parent)
if n.id == GLYPH then
texio.write(utf8.char(n.char))
elseif n.id == GLUE then
+ texio.write(tostring(n.subtype))
real_pt = string.format("%.1fpt", effective_glue(n,parent)/65536)
texio.write(" realwd=" .. real_pt)
elseif n.id == DISC then
@@ -3059,13 +3111,16 @@ local print_subtype = function (node,parent)
end
texio.write(" post=" .. c)
end
- elseif n.subtype and n.subtype < 256 and n.height and n.depth then
- ht_pt = string.format("%.1fpt", n.height/65536)
- dp_pt = string.format("%.1fpt", n.depth/65536)
- texio.write(" ht=" .. ht_pt .. " dp=" .. dp_pt)
- if n.width then
- wd_pt = string.format("%.1fpt", n.width/65536)
- texio.write(" wd=" .. wd_pt)
+ elseif n.subtype and n.subtype < 256 then
+ texio.write(tostring(n.subtype))
+ if n.height and n.depth then
+ ht_pt = string.format("%.1fpt", n.height/65536)
+ dp_pt = string.format("%.1fpt", n.depth/65536)
+ texio.write(" ht=" .. ht_pt .. " dp=" .. dp_pt)
+ if n.width then
+ wd_pt = string.format("%.1fpt", n.width/65536)
+ texio.write(" wd=" .. wd_pt)
+ end
end
end
end