summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-02-11 21:44:36 +0000
committerKarl Berry <karl@freefriends.org>2023-02-11 21:44:36 +0000
commit456708a70378d3e2b02f26e326fbf82723743e00 (patch)
treedb195c2d662995207cb94a4bf74d3c4435e3407a
parentd350cc52b8f25cb3c7d31afd4e89ef7ccdce79ed (diff)
lua-typo (11feb23)
git-svn-id: svn://tug.org/texlive/trunk@65795 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/lualatex/lua-typo/README.md4
-rw-r--r--Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.pdfbin16859 -> 16859 bytes
-rw-r--r--Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-fr.pdfbin80360 -> 105225 bytes
-rw-r--r--Master/texmf-dist/doc/lualatex/lua-typo/lua-typo.pdfbin169623 -> 173735 bytes
-rw-r--r--Master/texmf-dist/source/lualatex/lua-typo/lua-typo.dtx566
-rw-r--r--Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.cfg16
-rw-r--r--Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty176
7 files changed, 460 insertions, 302 deletions
diff --git a/Master/texmf-dist/doc/lualatex/lua-typo/README.md b/Master/texmf-dist/doc/lualatex/lua-typo/README.md
index a9c6c7a2aa2..0930ac70cff 100644
--- a/Master/texmf-dist/doc/lualatex/lua-typo/README.md
+++ b/Master/texmf-dist/doc/lualatex/lua-typo/README.md
@@ -79,6 +79,10 @@ Changes
- this version should do a better job on two columns documents;
- debugging stuff added.
+* v.0.61:
+ - bug fixes and documentation enhanced.
+ - colours `mygrey` and `myred` renamed `LTgrey` and `LTred`.
+
--
Copyright 2020--2023 Daniel Flipo
E-mail: daniel (dot) flipo (at) free (dot) fr
diff --git a/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.pdf b/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.pdf
index 9b4721716e8..f5ea36a35e5 100644
--- a/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.pdf
+++ b/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-demo.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-fr.pdf b/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-fr.pdf
index 0b96add63d3..287b2660b57 100644
--- a/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-fr.pdf
+++ b/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo-fr.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo.pdf b/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo.pdf
index 4f50db55294..55acdc97b8e 100644
--- a/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo.pdf
+++ b/Master/texmf-dist/doc/lualatex/lua-typo/lua-typo.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/lualatex/lua-typo/lua-typo.dtx b/Master/texmf-dist/source/lualatex/lua-typo/lua-typo.dtx
index 29e087ccb13..9929679bc21 100644
--- a/Master/texmf-dist/source/lualatex/lua-typo/lua-typo.dtx
+++ b/Master/texmf-dist/source/lualatex/lua-typo/lua-typo.dtx
@@ -134,51 +134,78 @@
% L’extension \pkg{lua-typo} décrite ci-dessous%
% \footnote{Version \fileversion, mise à jour le \filedate.}
% permet de mettre en lumière par un changement de couleur, les
-% lignes typographiquement imparfaites d’un fichier PDF produit par
-% LuaLaTeX. Une liste des pages concernées est affichée à la fin du
-% fichier \file{.log}, permettant un accès rapide aux pages
-% potentiellement défectueuses.
+% lignes potentiellement imparfaites d’un fichier PDF produit par
+% LuaLaTeX ; comme son nom l’indique elle ne fonctionne qu’avec
+% LuaLaTeX. Une liste des pages concernées est affichée à la fin
+% du fichier \file{.log}, permettant un accès rapide aux pages
+% incriminées. \pkg{lua-typo} crée également un fichier de suffixe
+% \file{.typo} regroupant les informations (type, page, ligne) sur
+% les imperfections relevées.
%
% Normalement, c’est-à-dire lorsque la justification n’est pas trop
-% étroite, (Lua)TeX fait du bon travail, mais il peut rester des
-% points à vérifier, notamment des lignes trop pleines ou lavées
-% (\emph{Overfull, Underfull box}), des veuves et des orphelines,
-% des mots coupés en fin de page ou d’alinéa ou sur plusieurs
-% lignes consécutives, des dernières lignes d’alinéa trop courtes ou
-% presque pleines, des pages quasi vides.
+% étroite, (Lua)TeX fait du bon travail, surtout si \pkg{microtype}
+% est utilisé mais il peut rester des points à vérifier, notamment
+% des lignes trop pleines ou lavées (\emph{Overfull, Underfull box}),
+% des veuves et des orphelines, des mots coupés en fin de page ou
+% d’alinéa ou sur plusieurs lignes consécutives, des dernières lignes
+% d’alinéa trop courtes ou presque pleines, des pages quasi vides.
% La répétition d’un même mot ou partie de mot au début ou à la fin
% de deux lignes consécutives est aussi détectée.
-% La présence en fin de ligne de certains mots très courts (une ou
+% La présence en fin de ligne de certains mots très courts (une ou
% deux lettres, liste dépendant de la langue) peut également être
% recherchée.
%
-% \pkg{lua-typo}, ne fonctionne qu’avec LuaLaTeX et
-% \emph{ne corrige aucun des défauts relevés} mais se contente de
-% \emph{signaler} au relecteur les points qui peuvent nécessiter une
-% correction. Seul un humain entrainé peut décider si une ligne
-% légèrement lavée est acceptable ou non, ou si la suppression
-% d’une coupure malvenue ne va pas provoquer des désordres plus
-% graves encore.
-%
-% Un outil potentiellement utile est la commande TeX |\spaceskip|
-% qui, utilisée dans un groupe, permet de modifier localement
-% l’espace inter-mots. Un léger accroissement de celui-ci dans un
-% paragraphe peut rendre acceptable la dernière ligne de celui-ci
-% alors qu’elle était trop courte ou, si elle était presque pleine,
-% lui ajouter une ligne, supprimant ainsi une orpheline éventuelle.
-% De même une légère réduction de l’espace inter-mots peut supprimer
-% la dernière ligne (courte) d’un paragraphe et éviter une veuve en
-% début de la page suivante.
+% \textbf{Important :} a) les lignes totalement ou partiellement
+% coloriées par \pkg{lua-typo} le sont uniquement pour
+% \emph{attirer l’attention} du correcteur à qui il appartient
+% de décider si ces lignes doivent être remaniées ou non.
+% Certains « défauts » peuvent être acceptables dans certaines
+% conditions (multicolonnage, documents techniques) et pas dans
+% d’autres, œuvres litéraires par exemple.
+% Seul un humain entrainé peut décider si une ligne légèrement lavée
+% est acceptable ou non, ou si la suppression d’une coupure malvenue
+% 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.
+%
+% \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
+% \file{lua-typo.cfg}.
+%
+% \pkg{lua-typo} ne corrigeant aucun des « défauts » relevés, quels
+% sont les moyens à notre disposition pour le faire manuellement ?
+% Reformuler une phrase est souvent efficace, un auteur peut se le
+% permettre, un correcteur ne le peut pas. Il est possible de jouer
+% sur l’espace inter-mots grâce à la commande TeX \cs{spaceskip},
+% ou sur l’interlettrage grâce à la commande \cs{textls} de
+% \pkg{microtype} mais dans les deux cas, il faut le faire \emph{avec
+% parcimonie}%
+% \footnote{Le but ultime est de parvenir à un « gris typographique »,
+% aussi parfait que possible ; l’argument optionnel de \cs{textls} ne
+% devrait guère sortir de l’intervalle $[-5,+15]$ (unité
+% 1/1000\up{e}\,\texttt{em}) et \cs{spaceskip} devrait rester très
+% proche de l’espace-mot standard déterminée par les \cs{fontdimen}.}
+% pour que le remède ne soit pas pire que le mal.
+% Un \emph{léger} accroissement de l’espace inter-mots ou de
+% l’interlettrage dans un groupe de mots peut rendre acceptable la
+% dernière ligne initialement trop courte d’un paragraphe ou, si elle
+% était presque pleine, ajouter une ligne, ce qui peut permettre
+% de supprimer une orpheline.
+% De même une légère contraction peut supprimer la dernière ligne
+% (courte) d’un paragraphe et éviter une veuve en début de la page
+% suivante.
%
% Je conseille de n’appliquer \pkg{lua-typo} que sur des textes
% « presque au point », d’améliorer ce qui peut l’être puis de
% \emph{supprimer} l’appel à \pkg{lua-typo} afin de ne pas risquer
% de mettre en lumière les imperfections que l’on aura renoncé
-% à corriger. Pour appliquer toutes les vérifications prévues par
-% \pkg{lua-typo}, il suffit d’ajouter dans le préambule la ligne\\
+% à corriger. Pour appliquer toutes les vérifications proposées par
+% \pkg{lua-typo}, il suffit d’ajouter dans le préambule la ligne %\\
% |\usepackage[All]{lua-typo}|
%
-% La version courante (0.60) nécessite un noyau LaTeX récent,
+% La version courante (0.61) 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
% «\texttt{Unable to register callback}» ; une version «rollback »
@@ -188,11 +215,12 @@
% Les fichiers \file{demo.tex} et \file{demo.pdf} fournissent un
% exemple du traitement opéré par \pkg{lua-typo}.
%
-% \pagebreak[4]
% Un grand merci à Jacques André et Thomas Savary pour avoir accepté
% de tester les pré-versions et pour leurs retours riches et toujours
% pertinents ; leurs suggestions et leurs encouragements ont
% grandement contribué à améliorer la première version mise en ligne.
+% Merci également à Michel Bovani pour ses remarques et suggestions
+% qui ont conduit à la version~0.61.
%
% \section{Utilisation}
%
@@ -205,10 +233,12 @@
% Pour tout activer sauf les options \meta{OptX} et \meta{OptY} :\\
% |\usepackage[All, |\meta{OptX}|=false, |\meta{OptY}|=false]{lua-typo}|\\
% ou pour se limiter aux tests \meta{OptX} et \meta{OptY} :\\
-% |\usepackage[|\meta{OptX}|, |\meta{OptY}|, |\meta{OptZ}|]{lua-typo}|
+% |\usepackage[|\meta{OptX}|, |\meta{OptY}|]{lua-typo}|
%
+% \pagebreak[4]
% Le tableau suivant donne le nom des options et le type des
-% vérifications proposées :\\[12pt]
+% vérifications proposées :
+%
% \begin{tabular}{>{\ttfamily}ll}
% \multicolumn{1}{l}{Nom} & Imperfection à signaler\\ \hline
% All & Active toutes les options ci-dessous\\
@@ -229,7 +259,8 @@
% consécutives ?\\
% FootnoteSplit & Fin de note de bas de page sur page suivante?\\
% \hline
-% \end{tabular}\\[12pt]
+% \end{tabular}
+%
% Par exemple, pour limiter les vérifications aux lignes trop pleines
% ou creuses, il suffit de coder :\\
% |\usepackage[OverfullLines, UnderfullLines]{lua-typo}|\\
@@ -262,28 +293,14 @@
% \item[FirstWordMatch :] les répétitions en début de ligne dans les
% listes ne sont pas signalées. Ceci est voulu car elles résultent
% d’un choix délibéré de l’auteur.
-% \item[LastWordMatch:] le dernier mot d’un alinéa qui se termine
-% à plus de |1em| (en fait |\luatypoBackPI|) de la marge droite
-% n’est jamais signalé comme répétition, même s’il est identique
-% au mot de la ligne du dessus.
-% De même, s’il est identique au dernier mot de la ligne
-% suivante, la répéttion ne sera pas signalée non plus.
% \item[ShortPages :] lorsque le nombre de lignes d’une page est jugé
% insuffisant (voir ci-dessous), seule la dernière ligne de celle-ci
% est mise en couleur.
-% \enlargethispage*{\baselineskip}
% \item[RepeatedHyphens :] de même, lorsque le nombre de lignes
% consécutives affectées par des coupures dépasse le seuil fixé
% (voir ci-dessous), ne sont coloriées que les coupures en excès.
% \end{description}
%
-% À partir de la version~0.50, le contenu des notes de bas de pages
-% est également vérifié, les notes trop longues pour se terminer sur
-% la page de leur appel sont signalées (option \opt{FootnoteSplit}).
-% Un fichier de suffixe \file{.typo} est créé, il contient la liste
-% complète des défauts repérés avec leur localisation dans le fichier
-% de sortie.
-%
% \section{Paramétrage personnalisé}
%
% Pour certaines vérifications faites par \pkg{lua-typo} un
@@ -313,10 +330,14 @@
% |luatypo| afin d’éviter de possibles conflits avec d’autres
% extensions.
% \begin{description}
-% \item[BackParindent :] la dernière ligne d’un alinéa fixe
-% devrait, soit être pleine ---~en fait se terminer à moins de
-% |\luatypoBackFuzz=2pt| de la marge droite~---, soit
-% s’en éloigner d’au moins de |\luatypoBackPI=1em|.
+% \item[BackParindent :] la dernière ligne d’un alinéa
+% devrait, soit se terminer à plus de |\luatypoBackPI=1em|
+% de la marge droite, soit être (approximativement) pleine
+% (tolérance |\luatypoBackFuzz=2pt|)%
+% \footnote{Certains auteurs n’acceptent pas les lignes pleines
+% en fin de paragraphe, ceux-là pourront faire
+% \cs{luatypoBackFuzz=0pt} pour qu’elles soient détectées comme
+% fautives.}.
%
% \item[ShortLines :] |\luatypoLLminWD=2\parindent|%
% \footnote{Ou \texttt{20pt} si \cs{parindent=0pt}.}
@@ -363,8 +384,8 @@
% Lorsque les listes correspondant à la langue du document sont
% vides, aucune vérification n’est effectuée. Pour l’instant,
% il y a deux lignes (non actives) prévues pour le français :\\
-% |\luatypoOneChar{french}{'À à Ô'}|\\
-% |\luatypoTwoChars{french}{'Je Tu Il On'}|
+% |\luatypoOneChar{french}{'À Ô Y'}|\\
+% |\luatypoTwoChars{french}{'Je Tu Il On Au De'}|
%
% Deux contraintes sont à respecter lorsqu’on veut
% personnaliser ces listes :\\
@@ -386,8 +407,8 @@
% Actuellement, seulement cinq couleurs sont utilisées par défaut,
% voici leur définition dans \file{lua-typo.cfg} :
% \begin{verbatim}
-% \definecolor{mygrey}{gray}{0.6}
-% \definecolor{myred}{rgb}{1,0.55,0}
+% \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
@@ -398,16 +419,16 @@
% \luatypoSetColor7{blue} % Ligne trop pleine
% \luatypoSetColor8{blue} % Ligne creuse
% \luatypoSetColor9{red} % Page presque vide (qq. lignes)
-% \luatypoSetColor{10}{myred} % Répétitions en début de ligne
-% \luatypoSetColor{11}{myred} % Répétitions en fin de ligne
-% \luatypoSetColor{12}{mygrey}% Dernière ligne d’alinéa presque pleine
+% \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 d’alinéa presque pleine
% \luatypoSetColor{13}{cyan} % Note de bas de page éclatée
% \end{verbatim}
% \pkg{lua-typo} charge l’extension graphique \pkg{color}.
% Seules les couleurs portant un nom (\emph{named colors}) peuvent
% être utilisées ; pour en définir de nouvelles, il faut donc soit
% utiliser la commande |\definecolor| de l’extension \pkg{color}
-% (comme ci-dessus pour |mygrey| ou |myred|), soit charger l’extension
+% (comme ci-dessus pour |LTgrey| ou |LTred|), soit charger l’extension
% \pkg{xcolor} package qui donne accès à une kyrielle de noms de
% couleurs.
% \end{FrenchDoc}
@@ -427,29 +448,46 @@
% section has version number \fileversion\ and was last revised on
% \filedate.}, is meant for careful writers and proofreaders who do
% not feel totally satisfied with LaTeX output, the most frequent
-% issues being widows and orphans, hyphenated words split across two
-% pages, consecutive lines ending with hyphens, paragraphs ending
-% on too short or nearly full lines, homeoarchy, etc.
+% issues being overfull or underfull lines, widows and orphans,
+% hyphenated words split across two pages, consecutive lines ending
+% with hyphens, paragraphs ending on too short or nearly full lines,
+% homeoarchy, etc.
%
% This package, which works with LuaLaTeX only,
% \emph{does not try to correct anything} but just highlights
% potential issues (the offending lines or end of lines are printed
% in colour) and provides at the end of the \file{.log} file a summary
-% of pages to be checked and manually corrected if possible.
-% My understanding is that automatic correction often introduces new
-% issues (underflow/overfull lines) when fixing one of the flaws
-% mentionned above, human correction providing much better results.
-% For completeness, overfull and underfull lines are also coloured
-% (in blue by default) and mentionned in the summary provided at the
-% end of the \file{.log} file.
-%
-% The TeX commands |\spaceskip| and |\xspaceskip| which alter the
-% inter-word spacing (locally when used in a group) should be
-% considered: slightly enlarging the inter-word space may be
-% sufficient to make a paragraph’s last line acceptable when it was
-% originally too short or add a line to a paragraph when its last
+% of pages to be checked and manually improved if possible.
+% \pkg{lua-typo} also creates a \file{<jobname>.typo} file which
+% summarises the informations (type, page, line number) about the
+% detected issues.
+%
+% \textbf{Important notice:} a) the highlighted lines are only meant
+% to \emph{draw the proofreader’s attention} on possible issues, it
+% is up to him/her to decide whether an improvement is desirable or
+% not; they should \emph{not} be regarded as blamable! some issues
+% may be acceptable in some conditions (multi-columns, technical
+% papers) and unbearable in others (literary works f.i.).
+% Moreover, correcting a potential issue somewhere may result in
+% other much more serious flaws elsewhere…\\
+% b) Conversely, possible bugs in \pkg{lua-typo} might hide issues
+% that should normally be highlighted.
+%
+% \pkg{lua-typo} is highly configurable in order to meet the
+% variable expectations of authors and correctors: see the options’
+% list and the \file{lua-typo.cfg} configuration file below.
+%
+% When \pkg{lua-typo} shows possible flaws in the page layout,
+% how can we fix them? The simpliest way is to rephrase some bits of
+% text… this is an option for an author, not for a proofreader.
+% When the text can not be altered, it is possible to \emph{slightly}
+% adjust the inter-word spacing (via the TeX commands |\spaceskip| and
+% |\xspaceskip|) and/or the letter spacing (via \pkg{microtype}’s
+% |\textls| command): slightly enlarging either of them or both may
+% be sufficient to make a paragraph’s last line acceptable when it
+% was originally too short or add a line to a paragraph when its last
% line was nearly full, thus possibly removing an orphan.
-% Conversely, slightly reducing it may remove a paragraph’s last line
+% Conversely, slightly reducing them may remove a paragraph’s last line
% (when it was short) and get rid of a widow on top of next page.
%
% I suggest to add a call |\usepackage[All]{lua-typo}| to the
@@ -470,7 +508,8 @@
% I am very grateful to Jacques André and Thomas Savary, who kindly
% tested my beta versions, providing much valuable feedback and
% suggesting many improvements for the first released version.
-% Special thanks to both of them!
+% Special thanks to both of them and to Michel Bovani whose
+% contributions led to version~0.61!
%
% \section{Usage}
%
@@ -520,6 +559,7 @@
% this option provides an easy way to get their names without having
% to look into the documentation.
%
+% \enlargethispage*{\baselineskip}
% 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
@@ -532,24 +572,12 @@
% \item[FirstWordMatch:] the first word of consecutive list items
% is not highlighted, as these repetitions result of the author’s
% choice.
-% \item[LastWordMatch:] a paragraphs’ last word ending ``too far’’
-% from the right margin (\emph{i.e.} more than
-% |\luatypoBackPI| --default=1em-- away) is never highlighted
-% even if it matches the one on the previous line.
-% Similarly, if it matches the one on the next line, the latter
-% will not be highlighted either.
% \item[ShortPages:] if a page is considered too short, its last
% line only is highlighted, not the whole page.
% \item[RepeatedHyphens:] ditto, when the number of consecutives
% hyphenated lines is too high, only the hyphenated words in
% excess (the last ones) are hightlighted.
% \end{description}
-% \enlargethispage*{\baselineskip}
-% Starting with version~0.50, the footnotes’ contents are checked as
-% well by \pkg{lua-typo} and footnotes too long to end on the current
-% page are mentionned as a flaw (option \opt{FootnoteSplit}).
-% The list of all flaws found is written to a specific log-file whose
-% name is suffixed by \file{.typo}.
%
% \section{Customisation}
%
@@ -575,11 +603,13 @@
% Here are the parameters names (all prefixed by |luatypo| in order
% to avoid conflicts with other packages) and their default values:
% \begin{description}
-% \item[BackParindent :] paragraphs’ last line should either
-% touch the right margin (actually end at less than
-% |\luatypoBackFuzz|, default |2pt|, from it) or leave at least
-% |\luatypoBackPI|, default |1em|, between its end and the right
-% margin.
+% \item[BackParindent :] paragraphs’ last line should either end at
+% at sufficient distance (|\luatypoBackPI|, default |1em|) of the
+% right margin, or (approximately) touch the right margin ---the
+% tolerance is |\luatypoBackFuzz| (default |2pt|)%
+% \footnote{Some authors do not accept full lines at end of
+% paragraphs, they can just set \cs{luatypoBackFuzz=0pt}
+% to make them pointed out as faulty.}.
%
% \item[ShortLines:] |\luatypoLLminWD=2\parindent|%
% \footnote{Or \texttt{20pt} if \cs{parindent=0pt}.}
@@ -622,8 +652,8 @@
%
% Currently, defaults (commented out) are suggested for the French
% language only:\\
-% |\luatypoOneChar{french}{'À à Ô'}|\\
-% |\luatypoTwoChars{french}{'Je Tu Il On'}|
+% |\luatypoOneChar{french}{'À Ô Y'}|\\
+% |\luatypoTwoChars{french}{'Je Tu Il On Au De'}|
%
% Feel free to customise these lists for French or to add your
% own shorts words for other languages but remember that
@@ -641,8 +671,8 @@
% typographic flaws that \pkg{lua-typo} deals with.
% Currently, only five colours are used in \file{lua-typo.cfg}:
% \begin{verbatim}
-% \definecolor{mygrey}{gray}{0.6}
-% \definecolor{myred}{rgb}{1,0.55,0}
+% \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
@@ -653,16 +683,16 @@
% \luatypoSetColor7{blue} % Overfull lines
% \luatypoSetColor8{blue} % Underfull lines
% \luatypoSetColor9{red} % Nearly empty page (a few lines)
-% \luatypoSetColor{10}{myred} % First word matches
-% \luatypoSetColor{11}{myred} % Last word matches
-% \luatypoSetColor{12}{mygrey}% paragraph’s last line nearly full
+% \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
% \end{verbatim}
%
% \pkg{lua-typo} loads the \pkg{color} package from the LaTeX graphic
% bundle. Only named colours can be used by \pkg{lua-typo}, so you
% can either use the |\definecolor| from \pkg{color} package to
-% define yours (as done in the config file for `mygrey’) or load the
+% define yours (as done in the config file for `LTgrey’) or load the
% \pkg{xcolor} package which provides a bunch of named colours.
%
% \clearpage
@@ -679,7 +709,7 @@
%<+scan>\ProvidesPackage{scan-page}
%<+dtx>\ProvidesFile{lua-typo.dtx}
%<*dtx|sty|scan>
- [2023-02-04 v.0.60 Daniel Flipo]
+ [2023-02-10 v.0.61 Daniel Flipo]
%</dtx|sty|scan>
%<*sty>
% \fi
@@ -1025,7 +1055,7 @@ luatypo = { }
% the fourteen types of possible typographic flaws.
% The first argument is a number (flaw type), the second the named
% colour associated to it.
-% The colour support is based on the \pkg{luacolor} package (color
+% The colour support is based on the \pkg{luacolor} package (colour
% attributes).
% \begin{macrocode}
\newcommand*{\luatypoSetColor}[2]{%
@@ -1046,7 +1076,7 @@ luatypo.double = { }
luatypo.colortbl = { }
luatypo.pagelist = " "
luatypo.buffer = "List of typographic flaws found for "
- .. tex.jobname .. ".tex:\string\n\string\n"
+ .. tex.jobname .. ".pdf:\string\n\string\n"
local char_to_discard = { }
char_to_discard[string.byte(",")] = true
@@ -1242,7 +1272,7 @@ log_flaw= function (msg, line, colno, footnote)
end
% \end{macrocode}
%
-% The next three functions deal with ``homeoarchy'', \emph{i.e.}
+% The next three functions deal with ``homeoarchy’’, \emph{i.e.}
% lines beginning or ending with the same (part of) word.
% While comparing two words, the only significant nodes are glyphs
% and ligatures, dicretionnaries other than ligatures, kerns
@@ -1334,21 +1364,25 @@ end
% \end{macrocode}
%
% This auxillary function looks for consecutive lines ending with the
-% same letters.
-% It requires four arguments: a string (previous line’s signature),
-% a node (the last one on the current line), a line number and
-% a boolean to cancel checking in some cases (end of paragraphs).
+% same letters.\par
+% It requires five arguments: a string (previous line’s signature),
+% a node (the last one on the current line), a line number, a column
+% number (possibly |nil|) and a boolean to cancel checking in some
+% cases (end of paragraphs).\par
% It prints the matching part at end of linewith with the supplied
% colour and returns the current line’s last word and a boolean (match).
%
-% \changes{v0.32}{2021/03/14}{Functions `check\_last\_word’ and
+% \changes{v0.32}{2021/03/14}{Functions `check\_first\_word’ and
% `check\_last\_word’ rewritten.}
%
% \changes{v0.50}{2021/05/13}{Homeoarchy detection added for lines
-% starting or ending on \cs{mbox}.}
+% starting or ending on \cs{mbox}.}
+%
+% \changes{v0.61}{2023/02/06}{`check\_last\_word’ returns a flag
+% to set pageflag.}
%
% \begin{macrocode}
-local check_last_word = function (old, node, line, flag)
+local check_last_word = function (old, node, line, colno, flag)
local COLOR = luatypo.colortbl[11]
local match = false
local new = ""
@@ -1437,13 +1471,12 @@ local check_last_word = function (old, node, line, flag)
newsub = nsub
end
end
- pageflag = true
newsub = string.gsub(newsub, '^_', '')
%<dbg> texio.write_nl('EOLfullmatch=' .. newsub)
local msg = "E.O.L. MATCH=" .. newsub
log_flaw(msg, line, colno, footnote)
% \end{macrocode}
-% Lest's colour the matching string.
+% Lest’s colour the matching string.
% \begin{macrocode}
oldsub = string.reverse(newsub)
local newsub = ""
@@ -1463,15 +1496,18 @@ local check_last_word = function (old, node, line, flag)
until newsub == oldsub or l >= k
end
end
- return new
+ return new, match
end
% \end{macrocode}
%
% Same thing for beginning of lines: check the first two words
% and compare their signature with the previous line’s.
%
+% \changes{v0.61}{2023/02/06}{`check\_first\_word’ returns a flag
+% to set pageflag.}
+%
% \begin{macrocode}
-local check_first_word = function (old, node, line, flag)
+local check_first_word = function (old, node, line, colno, flag)
local COLOR = luatypo.colortbl[10]
local match = false
local swap = false
@@ -1559,7 +1595,6 @@ local check_first_word = function (old, node, line, flag)
newsub = nsub
end
end
- pageflag = true
newsub = string.gsub(newsub, '_$', '') --$
%<dbg> texio.write_nl('BOLfullmatch=' .. newsub)
local msg = "B.O.L. MATCH=" .. newsub
@@ -1586,22 +1621,27 @@ local check_first_word = function (old, node, line, flag)
until newsub == oldsub or l >= k
end
end
- return new
+ return new, match
end
% \end{macrocode}
%
+% \pagebreak[4]
% This auxillary function looks for a short word (one or two chars)
% at end of lines, compares it to a given list and colours it if
% matches. The first argument must be a node of type |GLYPH|,
-% usually the last line’s node, the second one is the line number.\par
+% usually the last line’s node, the next two are the line and
+% column number.\par
% TODO: where does ``out of range’’ starts? U+0100? U+0180?
%
+% \changes{v0.61}{2023/02/06}{`check\_regexpr’ returns a flag
+% to set pageflag in `check\_vtop’.}
+%
% \begin{macrocode}
-local check_regexpr = function (glyph, line)
- local pageno = tex.getcount("c@page")
+local check_regexpr = function (glyph, line, colno)
local COLOR = luatypo.colortbl[3]
local lang = glyph.lang
local match = false
+ local retflag = false
local lchar, id = is_glyph(glyph)
local previous = glyph.prev
% \end{macrocode}
@@ -1614,7 +1654,7 @@ local check_regexpr = function (glyph, line)
if lchar and lchar < 0x100 and previous and previous.id == GLUE then
match = string.find(luatypo.single[lang], string.char(lchar))
if match then
- pageflag = true
+ retflag = true
local msg = "RGX MATCH=" .. string.char(lchar)
log_flaw(msg, line, colno, footnote)
color_node(glyph,COLOR)
@@ -1635,7 +1675,7 @@ local check_regexpr = function (glyph, line)
local pattern = string.char(pchar) .. string.char(lchar)
match = string.find(luatypo.double[lang], pattern)
if match then
- pageflag = true
+ retflag = true
local msg = "RGX MATCH=" .. pattern
log_flaw(msg, line, colno, footnote)
color_node(previous,COLOR)
@@ -1655,8 +1695,8 @@ local check_regexpr = function (glyph, line)
local pattern = string.char(pchar) .. string.char(lchar)
match = string.find(luatypo.double[lang], pattern)
if match then
- pageflag = true
- local msg = "RGX MATCH=" .. pattern
+ retflag = true
+ local msg = "REGEXP MATCH=" .. pattern
log_flaw(msg, line, colno, footnote)
color_node(pprev,COLOR)
color_node(glyph,COLOR)
@@ -1665,6 +1705,7 @@ local check_regexpr = function (glyph, line)
end
end
end
+return retflag
end
% \end{macrocode}
%
@@ -1788,7 +1829,7 @@ end
% \begin{macro}{check-vtop}
% This function is called repeatedly by |check_page| (see below);
% it scans the boxes found in the page body (f.i. columns)
-% in search of typographical flaws and logs them if it finds any.
+% in search of typographical flaws and logs.
%
% \changes{v0.40}{2021/04/18}{Title pages, pages with figures and/or
% tables may not be empty pages: check `vpos’ last line’s position.}
@@ -1831,8 +1872,7 @@ check_vtop = function (head, colno, vpos)
local footnote = false
local ftnsplit = false
local orphanflag = false
- local widowflag = false
- local lwhyphflag = false
+ local widowflag = false
local pageshort = false
local firstwd = ""
local lastwd = ""
@@ -1843,8 +1883,6 @@ check_vtop = function (head, colno, vpos)
local body_bottom = false
local page_bottom = false
local pageflag = false
- local plist = luatypo.pagelist
- local lastp = tonumber(string.match(plist, "%s(%d+),%s$"))
local pageno = tex.getcount("c@page")
% \end{macrocode}
% The main loop scans the content of the |\vtop| holding the page
@@ -1853,18 +1891,19 @@ check_vtop = function (head, colno, vpos)
while head do
local nextnode = head.next
% \end{macrocode}
-% Let's scan the top nodes of this vbox: expected are \node{hlist}
+% Let’s scan the top nodes of this vbox: expected are \node{hlist}
% (text lines or vboxes), \node{rule}, \node{kern}, \node{glue}…
% \begin{macrocode}
if head.id == HLIST and head.subtype == LINE and
(head.height > 0 or head.depth > 0) then
% \end{macrocode}
-% This is a text line, store the line width, increment counters
+% This is a text line, store its width, increment counters
% |pageline| or |ftnline| and |line| (for |log_flaw|).
-% Let’s update |vpos| (vertical position in `sp' units) too.
+% Let’s update |vpos| (vertical position in `sp’ units) too.
% \begin{macrocode}
vpos = vpos + head.height + head.depth
- linewd = head.width
+ local linewd = head.width
+ local first = head.head
if footnote then
ftnline = ftnline + 1
line = ftnline
@@ -1873,8 +1912,9 @@ check_vtop = function (head, colno, vpos)
line = pageline
end
% \end{macrocode}
-% Is this line the last one on the page or before footnotes?\par
-% This has to be known early (orphanflag, lwhyphflag, ftnsplit).
+% Is this line the last one on the page or before footnotes?
+% This has to be known early in order to set the flags |orphanflag|
+% and |ftnsplit|.
% \begin{macrocode}
local n = nextnode
while n and (n.id == GLUE or n.id == PENALTY or
@@ -1895,7 +1935,6 @@ check_vtop = function (head, colno, vpos)
% \changes{v0.50}{2021/05/13}{Detection of overfull boxes fixed: the
% former code didn’t work for typewriter fonts.}
% \begin{macrocode}
- local first = head.head
local hmax = linewd + tex.hfuzz
local w,h,d = dimensions(1,2,0, first)
if w > hmax and OverfullLines then
@@ -1923,7 +1962,7 @@ check_vtop = function (head, colno, vpos)
ftnsplit = true
end
% \end{macrocode}
-% The current node is a line, |first| is the line’s first node.
+% The current node being a line, |first| is its first node.
% Skip margin kern and/or leftskip if any.
%
% \changes{v0.40}{2021/04/18}{Both MKERN and LFTSKIP may occur on
@@ -1944,7 +1983,7 @@ check_vtop = function (head, colno, vpos)
if first.id == LPAR then
% \end{macrocode}
% It starts a paragraph… Reset |parline| except in footnotes
-% (|parline| and |pageline| counts are for ``body'' \emph{only},
+% (|parline| and |pageline| counts are for ``body’’ \emph{only},
% they are frozen in footnotes).
% \begin{macrocode}
hyphcount = 0
@@ -1970,13 +2009,10 @@ check_vtop = function (head, colno, vpos)
parline = parline + 1
end
% \end{macrocode}
-% Let’s track lines beginning with the same word (except lists).
-% \begin{macrocode}
- if FirstWordMatch then
- local flag = not ListItem
- firstwd = check_first_word(firstwd, first, line, flag)
- 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.
% \begin{macrocode}
@@ -1992,7 +2028,9 @@ check_vtop = function (head, colno, vpos)
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.\par Orphans and widows will be colored later.
+% 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.
% \begin{macrocode}
if pageline == 1 and parline > 1 then
widowflag = true
@@ -2012,7 +2050,7 @@ check_vtop = function (head, colno, vpos)
% \begin{macrocode}
if llwd < LLminWD then
pageflag = true
- local msg = "SHORT LINE: " ..
+ local msg = "SHORT LINE: length=" ..
string.format("%.0fpt", llwd/65536)
log_flaw(msg, line, colno, footnote)
local COLOR = luatypo.colortbl[6]
@@ -2024,11 +2062,14 @@ check_vtop = function (head, colno, vpos)
end
end
% \end{macrocode}
-% Is this line nearly full? (ending too close to the right margin)
+% Does this (end of paragraph) line ends too close to the right
+% margin? If so, colour the whole line before checking matching
+% words.
% \begin{macrocode}
- if BackParindent and PFskip < BackPI and PFskip > BackFuzz then
+ if BackParindent and PFskip < BackPI and
+ PFskip >= BackFuzz and parline > 1 then
pageflag = true
- local msg = "LINE NEARLY FULL: missing " ..
+ local msg = "NEARLY FULL line: backskip=" ..
string.format("%.1fpt", PFskip/65536)
log_flaw(msg, line, colno, footnote)
local COLOR = luatypo.colortbl[12]
@@ -2036,22 +2077,95 @@ check_vtop = function (head, colno, vpos)
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
+ firstwd, flag =
+ check_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?
% \begin{macrocode}
if LastWordMatch then
- local flag = textline
+ local flag = true
if PFskip > BackPI then
flag = false
end
- lastwd = check_last_word(lastwd, pn, line, flag)
+ lastwd, flag =
+ check_last_word(lastwd, pn, line, colno, flag)
+ if flag then
+ pageflag = true
+ end
end
elseif pn and pn.id == DISC then
% \end{macrocode}
% 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
+ pageflag = true
+ local msg = "FOOTNOTE SPLIT"
+ 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}
+% This hyphen occurs on the page’s last line (body or footnote),
+% colour (differently) the last word.
+% \begin{macrocode}
+ pageflag = true
+ local msg = "LAST WORD SPLIT"
+ log_flaw(msg, line, colno, footnote)
+ local COLOR = luatypo.colortbl[1]
+ local pg = show_pre_disc (pn,COLOR)
+ end
+% \end{macrocode}
+% Track matching words at the beginning and end of line.
+% \begin{macrocode}
+ if FirstWordMatch then
+ local flag = not ListItem
+ firstwd, flag =
+ check_first_word(firstwd, first, line, colno, flag)
+ if flag then
+ pageflag = true
+ end
+ end
if LastWordMatch then
- lastwd = check_last_word(lastwd, ln, line, true)
+ local flag = false
+ lastwd, flag =
+ check_last_word(lastwd, ln, line, colno, true)
+ if flag then
+ pageflag = true
+ end
end
if hyphcount > HYPHmax and RepeatedHyphens then
local COLOR = luatypo.colortbl[2]
@@ -2060,18 +2174,11 @@ check_vtop = function (head, colno, vpos)
local msg = "REPEATED HYPHENS: more than " .. HYPHmax
log_flaw(msg, line, colno, footnote)
end
- if (page_bottom or body_bottom) and EOPHyphens then
-% \end{macrocode}
-% This hyphen occurs on the page’s last line (body or footnote).
-% \begin{macrocode}
- lwhyphflag = true
- end
if nextnode and ParLastHyphen then
% \end{macrocode}
% Does the next line end the current paragraph? If so, |nextnode| is
% a `linebreak penalty’, the next one is a `baseline skip’ and the
-% node after a \node{hlist} of subtype \node{line} with
-% |glue_order=2|.
+% node after is a \node{hlist-1} with |glue_order=2|.
% \begin{macrocode}
local nn = nextnode.next
local nnn = nil
@@ -2088,38 +2195,16 @@ check_vtop = function (head, colno, vpos)
end
end
% \end{macrocode}
-% CASE 3: the current line ends with anything else (\node{mkern},
-% \node{glyph}, \node{hlist}, etc.), reset |hyphcount|, perform
-% checks for `LastWordMatch’ and for `EOLShortWords’.
+% 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’.
% \begin{macrocode}
else
hyphcount = 0
- if LastWordMatch and pn then
- lastwd = check_last_word(lastwd, pn, line, true)
- end
- if EOLShortWords then
- while pn and pn.id ~= GLYPH and pn.id ~= HLIST do
- pn = pn.prev
- end
- if pn and pn.id == GLYPH then
- check_regexpr(pn,line)
- end
- end
- end
% \end{macrocode}
-% Colour the whole line if is is a widow.
-% \begin{macrocode}
- if widowflag and Widows then
- pageflag = true
- widowflag = false
- local msg = "WIDOW"
- log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[4]
- color_line (head, COLOR)
- end
-% \end{macrocode}
-% Colour the whole line if is is a orphan or footnote continuing
-% on the next page.
+% 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
@@ -2136,14 +2221,35 @@ check_vtop = function (head, colno, vpos)
color_line (head, COLOR)
end
% \end{macrocode}
-% Colour (differently) the last word if hyphenated.
+% Track matching words at the beginning and end of line and shot
+% words.
% \begin{macrocode}
- if lwhyphflag and EOPHyphens then
- pageflag = true
- local msg = "LAST WORD SPLIT"
- log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[1]
- local pg = show_pre_disc (pn,COLOR)
+ if FirstWordMatch then
+ local flag = not ListItem
+ firstwd, flag =
+ check_first_word(firstwd, first, line, colno, flag)
+ if flag then
+ pageflag = true
+ end
+ end
+ if LastWordMatch and pn then
+ local flag
+ lastwd, flag =
+ check_last_word(lastwd, pn, line, colno, true)
+ if flag then
+ pageflag = true
+ end
+ end
+ if EOLShortWords then
+ while pn and pn.id ~= GLYPH and pn.id ~= HLIST do
+ pn = pn.prev
+ end
+ if pn and pn.id == GLYPH then
+ if check_regexpr(pn, line, colno) then
+ pageflag = true
+ end
+ end
+ end
end
% \end{macrocode}
% End of scanning for the main type of node (text lines).
@@ -2168,7 +2274,7 @@ check_vtop = function (head, colno, vpos)
line = pageline
end
% \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
@@ -2222,9 +2328,7 @@ check_vtop = function (head, colno, vpos)
footnote = true
ftnline = 0
body_bottom = false
- ftnrule_ahead = false
orphanflag = false
- lwhyphflag = false
hyphcount = 0
firstwd = ""
lastwd = ""
@@ -2233,12 +2337,6 @@ check_vtop = function (head, colno, vpos)
% 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
-% NOTE1: |effective_glue| requires a `parent’ node, as pointed out by
-% Marcel Krüger on S.E., this implies using |pre_shipout_filter|
-% instead of |pre_output_filter|.\par
-% NOTE2: Widows are already detected, skip them here; there are
-% usually two consecutive nodes of type \node{glue}-0 at end of
-% pages…
% \begin{macrocode}
elseif body_bottom and head.id == GLUE and head.subtype == 0 then
if first_bot then
@@ -2306,16 +2404,18 @@ check_vtop = function (head, colno, vpos)
%<dbg> end
%<dbg> texio.write_nl('')
% \end{macrocode}
-% Record flaws:
+% Update the list of flagged pages avoiding duplicates:
% \begin{macrocode}
if pageflag then
+ local plist = luatypo.pagelist
+ local lastp = tonumber(string.match(plist, "%s(%d+),%s$"))
if not lastp or pageno > lastp then
luatypo.pagelist = luatypo.pagelist .. tostring(pageno) .. ", "
end
end
return head
% \end{macrocode}
-% head is nil unless |check_vtop| exited on a two column start.
+% |head| is nil unless |check_vtop| exited on a two column start.
% \begin{macrocode}
end
% \end{macrocode}
@@ -2356,6 +2456,9 @@ luatypo.check_page = function (head)
top = body.list
first = top.list
end
+% \end{macrocode}
+% Main loop:
+% \begin{macrocode}
while top do
first = top.list
%<dbg> texio.write_nl('Page loop: top=' .. tostring(node.type(top.id)))
@@ -2440,12 +2543,16 @@ return luatypo.check_page
% \end{macrocode}
% \end{macro}
%
+% NOTE: |effective_glue| requires a `parent’ node, as pointed out by
+% Marcel Krüger on S.E., this implies using |pre_shipout_filter|
+% instead of |pre_output_filter|.
+%
% Add the |luatypo.check_page| function to the |pre_shipout_filter|
-% callback (with priority 1 for color attributes to be effective),
+% callback (with priority 1 for colour attributes to be effective),
% unless option |None| is selected ; remember that the |None|
% boolean’s value is forwarded to Lua `AtEndOfPackage’…
%
-% \changes{v0.50}{2021/05/02}{Callback `pre\_output\_filter’ replaced
+% \changes{v0.50}{2021/05/02}{Callback `pre\_output\_filter’ replaced
% by `pre\_shipout\_filter’, in the former the material is not boxed
% yet and footnotes are not visible.}
%
@@ -2462,15 +2569,18 @@ return luatypo.check_page
%
% Load a local config file if present in LaTeX’s search path.\par
% Otherwise, set reasonnable defaults.
-% \enlargethispage*{\baselineskip}
+%
+% \changes{v0.61}{2023/02/07}{Colours mygrey, myred renamed
+% LTgrey, LTred.}
+%
% \begin{macrocode}
\InputIfFileExists{lua-typo.cfg}%
{\PackageInfo{lua-typo.sty}{'lua-typo.cfg' file loaded}}%
{\PackageInfo{lua-typo.sty}{'lua-typo.cfg' file not found.
\MessageBreak Providing default values.}%
- \definecolor{mygrey}{gray}{0.6}%
- \definecolor{myred}{rgb}{1,0.55,0}
+ \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
@@ -2481,9 +2591,9 @@ return luatypo.check_page
\luatypoSetColor7{blue}% Overfull lines
\luatypoSetColor8{blue}% Underfull lines
\luatypoSetColor9{red}% Nearly empty page
- \luatypoSetColor{10}{myred}% First word matches
- \luatypoSetColor{11}{myred}% Last word matches
- \luatypoSetColor{12}{mygrey}% Paragraph ending on a nearly full line
+ \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
\luatypoBackPI=1em\relax
\luatypoBackFuzz=2pt\relax
@@ -2533,9 +2643,9 @@ return luatypo.check_page
\luatypoMinFull=3\relax
\luatypoMinPart=4\relax
-%% Default colours = red, cyan, mygrey
-\definecolor{mygrey}{gray}{0.6}
-\definecolor{myred}{rgb}{1,0.55,0}
+%% Default colours = red, cyan, LTgrey
+\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
@@ -2546,15 +2656,15 @@ return luatypo.check_page
\luatypoSetColor7{blue} % Overfull lines
\luatypoSetColor8{blue} % Underfull lines
\luatypoSetColor9{red} % Nearly empty page (just a few lines)
-\luatypoSetColor{10}{myred} % First word matches
-\luatypoSetColor{11}{myred} % Last word matches
-\luatypoSetColor{12}{mygrey}% Paragraph ending on a nearly full line
+\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
%% Language specific settings (example for French):
%% short words (two letters max) to be avoided at end of lines.
-%%\luatypoOneChar{french}{'À à Ô'}
-%%\luatypoTwoChars{french}{'Je Tu Il On'}
+%%\luatypoOneChar{french}{'À Ô Y'}
+%%\luatypoTwoChars{french}{'Je Tu Il On Au De'}
% \end{macrocode}
%
% \iffalse
@@ -2832,7 +2942,7 @@ local scanvlist = function (head)
end
% \end{macrocode}
-% Add the main function to callback "pre\_shipout\_filter".
+% Add the main function to callback |pre_shipout_filter|.
% \begin{macrocode}
luatexbase.add_to_callback("pre_shipout_filter",scanvlist,"check_vlists")
% \end{macrocode}
diff --git a/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.cfg b/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.cfg
index 5ad15f92242..9a3a27405a6 100644
--- a/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.cfg
+++ b/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.cfg
@@ -23,9 +23,9 @@
\luatypoMinFull=3\relax
\luatypoMinPart=4\relax
-%% Default colours = red, cyan, mygrey
-\definecolor{mygrey}{gray}{0.6}
-\definecolor{myred}{rgb}{1,0.55,0}
+%% Default colours = red, cyan, LTgrey
+\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
@@ -36,15 +36,15 @@
\luatypoSetColor7{blue} % Overfull lines
\luatypoSetColor8{blue} % Underfull lines
\luatypoSetColor9{red} % Nearly empty page (just a few lines)
-\luatypoSetColor{10}{myred} % First word matches
-\luatypoSetColor{11}{myred} % Last word matches
-\luatypoSetColor{12}{mygrey}% Paragraph ending on a nearly full line
+\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
%% Language specific settings (example for French):
%% short words (two letters max) to be avoided at end of lines.
-%%\luatypoOneChar{french}{'À à Ô'}
-%%\luatypoTwoChars{french}{'Je Tu Il On'}
+%%\luatypoOneChar{french}{'À Ô Y'}
+%%\luatypoTwoChars{french}{'Je Tu Il On Au De'}
%%
%%
%% End of file `lua-typo.cfg'.
diff --git a/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty b/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty
index 4d64e57f297..fd7e4a1e5da 100644
--- a/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty
+++ b/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty
@@ -11,7 +11,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[2021/06/01]
\ProvidesPackage{lua-typo}
- [2023-02-04 v.0.60 Daniel Flipo]
+ [2023-02-10 v.0.61 Daniel Flipo]
\ifdefined\DeclareRelease
\DeclareRelease{v0.4}{2021-01-01}{lua-typo-2021-04-18.sty}
\DeclareCurrentRelease{}{2023-02-04}
@@ -280,7 +280,7 @@ luatypo.double = { }
luatypo.colortbl = { }
luatypo.pagelist = " "
luatypo.buffer = "List of typographic flaws found for "
- .. tex.jobname .. ".tex:\string\n\string\n"
+ .. tex.jobname .. ".pdf:\string\n\string\n"
local char_to_discard = { }
char_to_discard[string.byte(",")] = true
@@ -468,7 +468,7 @@ local signature = function (node, string, swap)
end
return len, str
end
-local check_last_word = function (old, node, line, flag)
+local check_last_word = function (old, node, line, colno, flag)
local COLOR = luatypo.colortbl[11]
local match = false
local new = ""
@@ -544,7 +544,6 @@ local check_last_word = function (old, node, line, flag)
newsub = nsub
end
end
- pageflag = true
newsub = string.gsub(newsub, '^_', '')
local msg = "E.O.L. MATCH=" .. newsub
log_flaw(msg, line, colno, footnote)
@@ -566,9 +565,9 @@ local check_last_word = function (old, node, line, flag)
until newsub == oldsub or l >= k
end
end
- return new
+ return new, match
end
-local check_first_word = function (old, node, line, flag)
+local check_first_word = function (old, node, line, colno, flag)
local COLOR = luatypo.colortbl[10]
local match = false
local swap = false
@@ -644,7 +643,6 @@ local check_first_word = function (old, node, line, flag)
newsub = nsub
end
end
- pageflag = true
newsub = string.gsub(newsub, '_$', '') --$
local msg = "B.O.L. MATCH=" .. newsub
log_flaw(msg, line, colno, footnote)
@@ -667,20 +665,20 @@ local check_first_word = function (old, node, line, flag)
until newsub == oldsub or l >= k
end
end
- return new
+ return new, match
end
-local check_regexpr = function (glyph, line)
- local pageno = tex.getcount("c@page")
+local check_regexpr = function (glyph, line, colno)
local COLOR = luatypo.colortbl[3]
local lang = glyph.lang
local match = false
+ local retflag = false
local lchar, id = is_glyph(glyph)
local previous = glyph.prev
if lang and luatypo.single[lang] then
if lchar and lchar < 0x100 and previous and previous.id == GLUE then
match = string.find(luatypo.single[lang], string.char(lchar))
if match then
- pageflag = true
+ retflag = true
local msg = "RGX MATCH=" .. string.char(lchar)
log_flaw(msg, line, colno, footnote)
color_node(glyph,COLOR)
@@ -695,7 +693,7 @@ local check_regexpr = function (glyph, line)
local pattern = string.char(pchar) .. string.char(lchar)
match = string.find(luatypo.double[lang], pattern)
if match then
- pageflag = true
+ retflag = true
local msg = "RGX MATCH=" .. pattern
log_flaw(msg, line, colno, footnote)
color_node(previous,COLOR)
@@ -712,8 +710,8 @@ local check_regexpr = function (glyph, line)
local pattern = string.char(pchar) .. string.char(lchar)
match = string.find(luatypo.double[lang], pattern)
if match then
- pageflag = true
- local msg = "RGX MATCH=" .. pattern
+ retflag = true
+ local msg = "REGEXP MATCH=" .. pattern
log_flaw(msg, line, colno, footnote)
color_node(pprev,COLOR)
color_node(glyph,COLOR)
@@ -722,6 +720,7 @@ local check_regexpr = function (glyph, line)
end
end
end
+return retflag
end
local show_pre_disc = function (disc, color)
local n = disc
@@ -810,8 +809,7 @@ check_vtop = function (head, colno, vpos)
local footnote = false
local ftnsplit = false
local orphanflag = false
- local widowflag = false
- local lwhyphflag = false
+ local widowflag = false
local pageshort = false
local firstwd = ""
local lastwd = ""
@@ -822,15 +820,14 @@ check_vtop = function (head, colno, vpos)
local body_bottom = false
local page_bottom = false
local pageflag = false
- local plist = luatypo.pagelist
- local lastp = tonumber(string.match(plist, "%s(%d+),%s$"))
local pageno = tex.getcount("c@page")
while head do
local nextnode = head.next
if head.id == HLIST and head.subtype == LINE and
(head.height > 0 or head.depth > 0) then
vpos = vpos + head.height + head.depth
- linewd = head.width
+ local linewd = head.width
+ local first = head.head
if footnote then
ftnline = ftnline + 1
line = ftnline
@@ -849,7 +846,6 @@ check_vtop = function (head, colno, vpos)
elseif footnoterule_ahead(n) then
body_bottom = true
end
- local first = head.head
local hmax = linewd + tex.hfuzz
local w,h,d = dimensions(1,2,0, first)
if w > hmax and OverfullLines then
@@ -891,10 +887,6 @@ check_vtop = function (head, colno, vpos)
elseif not footnote then
parline = parline + 1
end
- if FirstWordMatch then
- local flag = not ListItem
- firstwd = check_first_word(firstwd, first, line, flag)
- end
local ln = slide(first)
local pn = ln.prev
if pn and pn.id == GLUE and pn.subtype == PARFILL then
@@ -909,7 +901,7 @@ check_vtop = function (head, colno, vpos)
local llwd = linewd - PFskip
if llwd < LLminWD then
pageflag = true
- local msg = "SHORT LINE: " ..
+ local msg = "SHORT LINE: length=" ..
string.format("%.0fpt", llwd/65536)
log_flaw(msg, line, colno, footnote)
local COLOR = luatypo.colortbl[6]
@@ -917,26 +909,81 @@ check_vtop = function (head, colno, vpos)
color_line (head, COLOR)
end
end
- if BackParindent and PFskip < BackPI and PFskip > BackFuzz then
+ if BackParindent and PFskip < BackPI and
+ PFskip >= BackFuzz and parline > 1 then
pageflag = true
- local msg = "LINE NEARLY FULL: missing " ..
+ 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
+ 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
+ if FirstWordMatch then
+ local flag = not ListItem
+ firstwd, flag =
+ check_first_word(firstwd, first, line, colno, flag)
+ if flag then
+ pageflag = true
+ end
+ end
if LastWordMatch then
- local flag = textline
+ local flag = true
if PFskip > BackPI then
flag = false
end
- lastwd = check_last_word(lastwd, pn, line, flag)
+ lastwd, flag =
+ check_last_word(lastwd, pn, line, colno, flag)
+ if flag then
+ pageflag = true
+ end
end
elseif pn and pn.id == DISC then
hyphcount = hyphcount + 1
+ 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
+ if (page_bottom or body_bottom) and EOPHyphens then
+ pageflag = true
+ local msg = "LAST WORD SPLIT"
+ log_flaw(msg, line, colno, footnote)
+ local COLOR = luatypo.colortbl[1]
+ local pg = show_pre_disc (pn,COLOR)
+ end
+ if FirstWordMatch then
+ local flag = not ListItem
+ firstwd, flag =
+ check_first_word(firstwd, first, line, colno, flag)
+ if flag then
+ pageflag = true
+ end
+ end
if LastWordMatch then
- lastwd = check_last_word(lastwd, ln, line, true)
+ local flag = false
+ lastwd, flag =
+ check_last_word(lastwd, ln, line, colno, true)
+ if flag then
+ pageflag = true
+ end
end
if hyphcount > HYPHmax and RepeatedHyphens then
local COLOR = luatypo.colortbl[2]
@@ -945,9 +992,6 @@ check_vtop = function (head, colno, vpos)
local msg = "REPEATED HYPHENS: more than " .. HYPHmax
log_flaw(msg, line, colno, footnote)
end
- if (page_bottom or body_bottom) and EOPHyphens then
- lwhyphflag = true
- end
if nextnode and ParLastHyphen then
local nn = nextnode.next
local nnn = nil
@@ -965,26 +1009,6 @@ check_vtop = function (head, colno, vpos)
end
else
hyphcount = 0
- if LastWordMatch and pn then
- lastwd = check_last_word(lastwd, pn, line, true)
- end
- if EOLShortWords then
- while pn and pn.id ~= GLYPH and pn.id ~= HLIST do
- pn = pn.prev
- end
- if pn and pn.id == GLYPH then
- check_regexpr(pn,line)
- end
- end
- end
- if widowflag and Widows then
- pageflag = true
- widowflag = false
- local msg = "WIDOW"
- log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[4]
- color_line (head, COLOR)
- end
if orphanflag and Orphans then
pageflag = true
local msg = "ORPHAN"
@@ -999,12 +1023,32 @@ check_vtop = function (head, colno, vpos)
local COLOR = luatypo.colortbl[13]
color_line (head, COLOR)
end
- if lwhyphflag and EOPHyphens then
- pageflag = true
- local msg = "LAST WORD SPLIT"
- log_flaw(msg, line, colno, footnote)
- local COLOR = luatypo.colortbl[1]
- local pg = show_pre_disc (pn,COLOR)
+ if FirstWordMatch then
+ local flag = not ListItem
+ firstwd, flag =
+ check_first_word(firstwd, first, line, colno, flag)
+ if flag then
+ pageflag = true
+ end
+ end
+ if LastWordMatch and pn then
+ local flag
+ lastwd, flag =
+ check_last_word(lastwd, pn, line, colno, true)
+ if flag then
+ pageflag = true
+ end
+ end
+ if EOLShortWords then
+ while pn and pn.id ~= GLYPH and pn.id ~= HLIST do
+ pn = pn.prev
+ end
+ if pn and pn.id == GLYPH then
+ if check_regexpr(pn, line, colno) then
+ pageflag = true
+ end
+ end
+ end
end
elseif head.id == HLIST and
(head.subtype == EQN or head.subtype == ALIGN) and
@@ -1055,9 +1099,7 @@ check_vtop = function (head, colno, vpos)
footnote = true
ftnline = 0
body_bottom = false
- ftnrule_ahead = false
orphanflag = false
- lwhyphflag = false
hyphcount = 0
firstwd = ""
lastwd = ""
@@ -1095,6 +1137,8 @@ check_vtop = function (head, colno, vpos)
head = nextnode
end
if pageflag then
+ local plist = luatypo.pagelist
+ local lastp = tonumber(string.match(plist, "%s(%d+),%s$"))
if not lastp or pageno > lastp then
luatypo.pagelist = luatypo.pagelist .. tostring(pageno) .. ", "
end
@@ -1170,8 +1214,8 @@ return luatypo.check_page
{\PackageInfo{lua-typo.sty}{'lua-typo.cfg' file loaded}}%
{\PackageInfo{lua-typo.sty}{'lua-typo.cfg' file not found.
\MessageBreak Providing default values.}%
- \definecolor{mygrey}{gray}{0.6}%
- \definecolor{myred}{rgb}{1,0.55,0}
+ \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
@@ -1182,9 +1226,9 @@ return luatypo.check_page
\luatypoSetColor7{blue}% Overfull lines
\luatypoSetColor8{blue}% Underfull lines
\luatypoSetColor9{red}% Nearly empty page
- \luatypoSetColor{10}{myred}% First word matches
- \luatypoSetColor{11}{myred}% Last word matches
- \luatypoSetColor{12}{mygrey}% Paragraph ending on a nearly full line
+ \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
\luatypoBackPI=1em\relax
\luatypoBackFuzz=2pt\relax