summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/impnattypo/README.md10
-rw-r--r--Master/texmf-dist/doc/latex/impnattypo/impnattypo-fr.pdfbin82309 -> 84319 bytes
-rw-r--r--Master/texmf-dist/doc/latex/impnattypo/impnattypo.pdfbin80478 -> 82522 bytes
-rw-r--r--Master/texmf-dist/source/latex/impnattypo/impnattypo.dtx165
-rw-r--r--Master/texmf-dist/source/latex/impnattypo/impnattypo.ins4
-rw-r--r--Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty77
6 files changed, 149 insertions, 107 deletions
diff --git a/Master/texmf-dist/doc/latex/impnattypo/README.md b/Master/texmf-dist/doc/latex/impnattypo/README.md
new file mode 100644
index 00000000000..11300805ce8
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/impnattypo/README.md
@@ -0,0 +1,10 @@
+Impnattypo
+==========
+
+[![Build Status](https://img.shields.io/travis/raphink/impnattypo/master.svg)](https://travis-ci.org/raphink/impnattypo)
+[![CTAN](https://img.shields.io/ctan/v/impnattypo.svg)](https://www.ctan.org/pkg/impnattypo)
+[![CTAN license](https://img.shields.io/ctan/l/impnattypo.svg)](https://www.ctan.org/pkg/impnattypo)
+
+This package provides useful macros implementing recommendations by the French Imprimerie Nationale. The documentation of this package is in French.
+
+Ce paquet fournit des macros utiles implémentant des recommendations de l'Imprimerie Nationale Française.
diff --git a/Master/texmf-dist/doc/latex/impnattypo/impnattypo-fr.pdf b/Master/texmf-dist/doc/latex/impnattypo/impnattypo-fr.pdf
index a46aa0798f4..58030516a8d 100644
--- a/Master/texmf-dist/doc/latex/impnattypo/impnattypo-fr.pdf
+++ b/Master/texmf-dist/doc/latex/impnattypo/impnattypo-fr.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/impnattypo/impnattypo.pdf b/Master/texmf-dist/doc/latex/impnattypo/impnattypo.pdf
index 431e1ea99b6..173447f2457 100644
--- a/Master/texmf-dist/doc/latex/impnattypo/impnattypo.pdf
+++ b/Master/texmf-dist/doc/latex/impnattypo/impnattypo.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/impnattypo/impnattypo.dtx b/Master/texmf-dist/source/latex/impnattypo/impnattypo.dtx
index 61bdccda949..856c15c2db9 100644
--- a/Master/texmf-dist/source/latex/impnattypo/impnattypo.dtx
+++ b/Master/texmf-dist/source/latex/impnattypo/impnattypo.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2011-2012 by Raphaël Pinson <raphink@gmail.com>
+% Copyright (C) 2011-2015 by Raphaël Pinson <raphink@gmail.com>
% ---------------------------------------------------------------------------
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -26,7 +26,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{impnattypo}
%<*package>
- [2015/02/25 1.4 Typographic utilities inspired by the French Imprimerie Nationale]
+ [2019/03/04 1.5 Typographic utilities inspired by the French Imprimerie Nationale]
%</package>
%
%<*driver>
@@ -44,7 +44,7 @@
\usepackage[svgnames]{xcolor}
\setmainfont{Linux Libertine O}
\usepackage{metalogo}
-\usepackage[draft,hyphenation,nosingleletter,parindent,lastparline,homeoarchy,rivers]{impnattypo}[2011/09/19]
+\usepackage[draft,hyphenation,nosingleletter,parindent,lastparline,homeoarchy,rivers]{impnattypo}[2018/06/04]
\usepackage[all]{nowidow}
\EnableCrossrefs
\CodelineIndex
@@ -76,6 +76,8 @@
% Right brace \} Tilde \~}
%
%
+% \changes{1.5}{2019/03/04}{Fix support for TexLive 2016 (new luatex
+% compatibility). Thanks to Michal Hoftich}
% \changes{1.4}{2015/02/25}{Fix release date}
% \changes{1.3}{2015/02/25}{Fix French documentation}
% \changes{1.2}{2013/06/18}{Fix French documentation}
@@ -123,7 +125,7 @@
%
% Such is the original goal of this package, initiated by a question on the
% tex.stackexchange.com\footnote{\url{http://tex.stackexchange.com/questions/20493/french-typography-recommendations}} website,
-% and which implements several of the rules listed in this booklet
+% and which implements several of the rules listed in this booklet
% so as to make them more easily applicable to texts edited with \LaTeX.
%
% As this package grew, functionalities were added, including some
@@ -134,7 +136,7 @@
% le \emph{Lexique des règles typographiques en usage à l'Imprimerie Nationale}
% est une référence incontournable.
%
-% Si la majorité des recommandations de cet ouvrage est implémentée dans
+% Si la majorité des recommandations de cet ouvrage est implémentée dans
% le module \textsf{frenchb} pour \textsf{babel},
% certaines autres recommandations méritent encore d'être automatisées pour être
% implémentées en \LaTeX.
@@ -289,7 +291,7 @@
% \ifenglish
% When this option is activated, only \LuaTeX{} (with the |lualatex| command)
% can render the document.
-%
+%
% When the \texttt{draft} option is activated,
% the inserted ties are colored in
% {\color{\intnosinglelettercolor}\intnosinglelettercolor}.
@@ -336,9 +338,9 @@
% \ifenglish
% When this option is activated, only \LuaTeX{} (with the |lualatex| command)
% can render the document.
-%
+%
% This option is only effective if the \texttt{draft} option is activated.
-%
+%
% The inserted ties are colored with two colors:
% \begin{itemize}
% \item Entire words are colored in
@@ -366,7 +368,7 @@
% Les espaces insécables insérées sont colorées de deux couleurs:
%
% \begin{itemize}
-% \item Les mots entiers sont colorés en
+% \item Les mots entiers sont colorés en
% {\color{\inthomeoarchywordcolor}\inthomeoarchywordcolor}
% et cette couleur peut être ajustée par l'option \texttt{homeoarchywordcolor};
% \item Les mots partiels sont colorés en
@@ -388,7 +390,7 @@
% \DescribeMacro{rivers}
% \ifenglish
% A river is a vertical alignment of spaces in a paragraph.
-% The \texttt{rivers} option allows to color rivers so as to
+% The \texttt{rivers} option allows to color rivers so as to
% identify them. This option does not fix the detected rivers:
% \else
% Une lézarde est un alignement vertical d'espaces dans un paragraphe.
@@ -403,13 +405,13 @@
% \ifenglish
% When this option is activated, only \LuaTeX{} (with the |lualatex| command)
% can render the document.
-%
+%
% This option is only effective if the \texttt{draft} option is activated.
-%
+%
% The inserted ties are colored in
% {\color{\intriverscolor}\intriverscolor}.
% This color can be tuned by means of the \texttt{riverscolor} option.
-% \else
+% \else
% Lorsque cette option est activée, seul \LuaTeX{} (via la commande |lualatex|)
% pourra effectuer le rendu du document.
%
@@ -468,11 +470,11 @@
% \let\frenchchapter\babylonian % numérotation en chiffres babyloniens
% \end{verbatim}
% \fi
-%
+%
%
% \ifenglish
% \subsection{Widows and Orphans}
-%
+%
% It is recommended not to leave widows and orphans in a document.
% For this reason, we recommend you use the |nowidow| package:
% \else
@@ -512,7 +514,7 @@
% \DescribeMacro{draft}
% Le paquet \textsf{impnattypo} dispose d'un mode brouillon
% permettant de visualiser les pénalités (espaces insécables)
-% ajoutés par les options \texttt{nosingleletter} et
+% ajoutés par les options \texttt{nosingleletter} et
% \texttt{lastparline}, ainsi que les informations
% ajoutées par les options \texttt{homeoarchy}
% et \texttt{rivers}. En mode brouillon,
@@ -589,13 +591,13 @@
% \begin{macrocode}
\ifintfrenchchapters
\let\frenchchapter\Roman
- \renewcommand{\thechapter}{%
+ \renewcommand{\thechapter}{%
\ifnum\value{chapter}=1
premier%
\else
\frenchchapter{chapter}%
\fi
- }
+ }
\fi
% \end{macrocode}
%
@@ -606,20 +608,23 @@
\ifluatex
\RequirePackage{luatexbase,luacode}
\begin{luacode}
-
+ local glyph_id = node.id "glyph"
+ local glue_id = node.id "glue"
+ local hlist_id = node.id "hlist"
+
local prevent_single_letter = function (head)
while head do
- if head.id == 37 then -- glyph
+ if head.id == glyph_id then -- glyph
if unicode.utf8.match(unicode.utf8.char(head.char),"%a") then -- some kind of letter
- if head.prev.id == 10 and head.next.id == 10 then -- only if we are at a one letter word
-
+ if head.prev.id == glue_id and head.next.id == glue_id then -- only if we are at a one letter word
+
local p = node.new("penalty")
p.penalty = 10000
-
+
\ifintdraft
local w = node.new("whatsit","pdf_literal")
w.data = "q \usecolor{\intnosinglelettercolor} 0 0 m 0 5 l 2 5 l 2 0 l b Q"
-
+
node.insert_after(head,head,w)
node.insert_after(head,w,p)
\else
@@ -632,7 +637,7 @@
end
return true
end
-
+
luatexbase.add_to_callback("pre_linebreak_filter",prevent_single_letter,"~")
\end{luacode}
\else
@@ -656,11 +661,15 @@
\ifluatex
\RequirePackage{luatexbase,luacode}
\begin{luacode}
+ local glyph_id = node.id "glyph"
+ local glue_id = node.id "glue"
+ local hlist_id = node.id "hlist"
+
last_line_twice_parindent = function (head)
while head do
local _w,_h,_d = node.dimensions(head)
- if head.id == 10 and head.subtype ~= 15 and (_w < 2 * tex.parindent) then
-
+ if head.id == glue_id and head.subtype ~= 15 and (_w < 2 * tex.parindent) then
+
-- we are at a glue and have less then 2*\parindent to go
local p = node.new("penalty")
p.penalty = 10000
@@ -668,19 +677,19 @@
\ifintdraft
local w = node.new("whatsit","pdf_literal")
w.data = "q \usecolor{\intlastparlinecolor} 0 0 m 0 5 l 2 5 l 2 0 l b Q"
-
+
node.insert_after(head,head.prev,w)
node.insert_after(head,w,p)
\else
node.insert_after(head,head.prev,p)
\fi
end
-
+
head = head.next
end
return true
end
-
+
luatexbase.add_to_callback("pre_linebreak_filter",last_line_twice_parindent,"lastparline")
\end{luacode}
\else
@@ -697,38 +706,42 @@
\ifluatex
\RequirePackage{luatexbase,luacode}
\begin{luacode}
+ local glyph_id = node.id "glyph"
+ local glue_id = node.id "glue"
+ local hlist_id = node.id "hlist"
+
compare_lines = function (line1,line2)
local head1 = line1.head
local head2 = line2.head
-
+
local char_count = 0
local word_count = 0
-
+
while head1 and head2 do
- if (head1.id == 37 and head2.id == 37
+ if (head1.id == glyph_id and head2.id == glyph_id
and head1.char == head2.char) -- identical glyph
- or (head1.id == 10 and head2.id == 10) then -- glue
-
- if head1.id == 37 then -- glyph
+ or (head1.id == glue_id and head2.id == glue_id) then -- glue
+
+ if head1.id == glyph_id then -- glyph
char_count = char_count + 1
- elseif char_count > 0 and head1.id == 10 then -- glue
+ elseif char_count > 0 and head1.id == glue_id then -- glue
word_count = word_count + 1
end
head1 = head1.next
head2 = head2.next
elseif (head1.id == 0 or head2.id == 0) then -- end of line
break
- elseif (head1.id ~= 37 and head1.id ~= 10) then -- some other kind of node
+ elseif (head1.id ~= glyph_id and head1.id ~= glue_id) then -- some other kind of node
head1 = head1.next
- elseif (head2.id ~= 37 and head2.id ~= 10) then -- some other kind of node
+ elseif (head2.id ~= glyph_id and head2.id ~= glue_id) then -- some other kind of node
head2 = head2.next
else -- no match, no special node
break
end
end
-- analyze last non-matching node, check for punctuation
- if ((head1 and head1.id == 37 and head1.char > 49)
- or (head2 and head2.id == 37 and head2.char > 49)) then
+ if ((head1 and head1.id == glyph_id and head1.char > 49)
+ or (head2 and head2.id == glyph_id and head2.char > 49)) then
-- not a word
elseif char_count > 0 then
word_count = word_count + 1
@@ -739,39 +752,39 @@
compare_lines_reverse = function (line1,line2)
local head1 = node.tail(line1.head)
local head2 = node.tail(line2.head)
-
+
local char_count = 0
local word_count = 0
while head1 and head2 do
- if (head1.id == 37 and head2.id == 37
+ if (head1.id == glyph_id and head2.id == glyph_id
and head1.char == head2.char) -- identical glyph
- or (head1.id == 10 and head2.id == 10) then -- glue
-
- if head1.id == 37 then -- glyph
+ or (head1.id == glue_id and head2.id == glue_id) then -- glue
+
+ if head1.id == glyph_id then -- glyph
char_count = char_count + 1
- elseif char_count > 0 and head1.id == 10 then -- glue
+ elseif char_count > 0 and head1.id == glue_id then -- glue
word_count = word_count + 1
end
head1 = head1.prev
head2 = head2.prev
elseif (head1.id == 0 or head2.id == 0) then -- start of line
break
- elseif (head1.id ~= 37 and head1.id ~= 10) then -- some other kind of node
+ elseif (head1.id ~= glyph_id and head1.id ~= glue_id) then -- some other kind of node
head1 = head1.prev
- elseif (head2.id ~= 37 and head2.id ~= 10) then -- some other kind of node
+ elseif (head2.id ~= glyph_id and head2.id ~= glue_id) then -- some other kind of node
head2 = head2.prev
- elseif (head1.id == 37 and head1.char < 48) then -- punctuation
+ elseif (head1.id == glyph_id and head1.char < 48) then -- punctuation
head1 = head1.prev
- elseif (head2.id == 37 and head2.char < 48) then -- punctuation
+ elseif (head2.id == glyph_id and head2.char < 48) then -- punctuation
head2 = head2.prev
else -- no match, no special node
break
end
end
-- analyze last non-matching node, check for punctuation
- if ((head1 and head1.id == 37 and head1.char > 49)
- or (head2 and head2.id == 37 and head2.char > 49)) then
+ if ((head1 and head1.id == glyph_id and head1.char > 49)
+ or (head2 and head2.id == glyph_id and head2.char > 49)) then
-- not a word
elseif char_count > 0 then
word_count = word_count + 1
@@ -791,7 +804,7 @@
-- insert node
n.next = line.head
- line.head = n
+ line.head = n
node.slide(line.head)
end
@@ -809,19 +822,19 @@
-- insert node
node.insert_after(line.head,nstart,n)
end
-
+
homeoarchy = function (head)
local cur_line = head
local prev_line -- initiate prev_line
-
+
local max_char = tonumber(\inthomeoarchymaxchars)
local max_word = tonumber(\inthomeoarchymaxwords)
-
+
while head do
- if head.id == 0 then -- new line
+ if head.id == hlist_id then -- new line
prev_line = cur_line
cur_line = head
- if prev_line.id == 0 then
+ if prev_line.id == hlist_id then
-- homeoarchy
char_count,word_count,prev_head,cur_head = compare_lines(prev_line,cur_line)
if char_count >= max_char or word_count >= max_word then
@@ -848,19 +861,19 @@
homoioteleuton = function (head)
local cur_line = head
local prev_line -- initiate prev_line
-
+
local max_char = tonumber(\inthomeoarchymaxchars)
local max_word = tonumber(\inthomeoarchymaxwords)
local linecounter = 0
-
+
while head do
- if head.id == 0 then -- new line
+ if head.id == hlist_id then -- new line
linecounter = linecounter + 1
if linecounter > 1 then
prev_line = cur_line
cur_line = head
- if prev_line.id == 0 then
+ if prev_line.id == hlist_id then
-- homoioteleuton
char_count,word_count,prev_head,cur_head = compare_lines_reverse(prev_line,cur_line)
if char_count >= max_char or word_count >= max_word then
@@ -870,7 +883,7 @@
else
color = "q \usecolor{\inthomeoarchycharcolor}"
end
-
+
-- highlight both lines
highlight_reverse(prev_head,prev_line,color)
highlight_reverse(cur_head,cur_line,color)
@@ -883,7 +896,7 @@
return true
end
-
+
luatexbase.add_to_callback("post_linebreak_filter",homoioteleuton,"homoioteleuton")
\end{luacode}
\else
@@ -901,14 +914,18 @@
\ifluatex
\RequirePackage{luatexbase,luacode}
\begin{luacode}
+local glyph_id = node.id "glyph"
+local glue_id = node.id "glue"
+local hlist_id = node.id "hlist"
+
river_analyze_line = function(line,dim1,dim2,precision)
local head = line.head
while head do
- if head.id == 10 then -- glue node
+ if head.id == glue_id then -- glue node
local w1,h1,d1 = node.dimensions(line.glue_set,line.glue_sign,line.glue_order,line.head,head.prev)
local w2,h2,d2 = node.dimensions(line.glue_set,line.glue_sign,line.glue_order,line.head,head)
- --print("dim1:"..dim1.."; dim2:"..dim2.."; w1:"..w1.."; w2:"..w2)
+ --print("dim1:"..dim1.."; dim2:"..dim2.."; w1:"..w1.."; w2:"..w2)
if w1 > dim2 + precision then -- out of range
return false,head
elseif w1 < (dim2 + precision) and w2 > (dim1 - precision) then -- found
@@ -931,7 +948,7 @@ rivers = function (head)
local linecounter = 0
while head do
- if head.id == 0 then -- new line
+ if head.id == hlist_id then -- new line
linecounter = linecounter + 1
prev_prev_line = prev_line
prev_line = cur_line
@@ -939,11 +956,11 @@ rivers = function (head)
if linecounter > 2 then
cur_node = cur_line.head
char_count = 0
-
+
while cur_node do
- if cur_node.id == 37 then -- glyph
+ if cur_node.id == glyph_id then -- glyph
char_count = char_count + 1
- elseif cur_node.id == 10 and char_count > 0 and cur_node.next then -- glue node
+ elseif cur_node.id == glue_id and char_count > 0 and cur_node.next then -- glue node
-- prev_line
local w1,h1,d1 = node.dimensions(head.glue_set,head.glue_sign,head.glue_order,head.head,cur_node.prev)
local w2,h2,d2 = node.dimensions(head.glue_set,head.glue_sign,head.glue_order,head.head,cur_node)
@@ -958,16 +975,16 @@ rivers = function (head)
-- if we allow up to 45° diagonal rivers, then there can be up to + or - line height between spaces
local w_p,h_p,d_p = node.dimensions(prev_prev_line.head,prev_line.head) -- calculate line height
found_pp,head_pp = river_analyze_line(prev_prev_line,w1,w2,h_p)
-
+
if found_pp then
local n_pp = node.new("whatsit","pdf_literal")
n_pp.data = "q \usecolor{\intriverscolor} 0 0 m 0 5 l 5 5 l 5 0 l b Q"
node.insert_after(prev_prev_line,head_pp.prev,n_pp)
-
+
local n_p = node.new("whatsit","pdf_literal")
n_p.data = "q \usecolor{\intriverscolor} 0 0 m 0 5 l 5 5 l 5 0 l b Q"
node.insert_after(prev_line,head_p.prev,n_p)
-
+
local n_c = node.new("whatsit","pdf_literal")
n_c.data = "q \usecolor{\intriverscolor} 0 0 m 0 5 l 5 5 l 5 0 l b Q"
node.insert_after(cur_line,cur_node.prev,n_c)
diff --git a/Master/texmf-dist/source/latex/impnattypo/impnattypo.ins b/Master/texmf-dist/source/latex/impnattypo/impnattypo.ins
index b3abf917884..0f8d7d1dd6f 100644
--- a/Master/texmf-dist/source/latex/impnattypo/impnattypo.ins
+++ b/Master/texmf-dist/source/latex/impnattypo/impnattypo.ins
@@ -1,4 +1,4 @@
-%% Copyright (C) 2011-2012 by Raphaël Pinson <raphink@gmail.com>
+%% Copyright (C) 2011-2015 by Raphaël Pinson <raphink@gmail.com>
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -25,7 +25,7 @@
This is a generated file.
-Copyright (C) 2011-2012 by Raphaël Pinson <raphink@gmail.com>
+Copyright (C) 2011-2015 by Raphaël Pinson <raphink@gmail.com>
--------------------------------------------------------------------------
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3
diff --git a/Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty b/Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty
index 52eff956ef5..1344a5dba7c 100644
--- a/Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty
+++ b/Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty
@@ -8,7 +8,7 @@
%%
%% This is a generated file.
%%
-%% Copyright (C) 2011-2012 by Raphaël Pinson <raphink@gmail.com>
+%% Copyright (C) 2011-2015 by Raphaël Pinson <raphink@gmail.com>
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -20,7 +20,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{impnattypo}
- [2015/02/25 1.4 Typographic utilities inspired by the French Imprimerie Nationale]
+ [2019/03/04 1.5 Typographic utilities inspired by the French Imprimerie Nationale]
\ProvidesPackage{impnattypo}
\RequirePackage{ifluatex}
\RequirePackage{kvoptions}
@@ -64,12 +64,15 @@
\ifluatex
\RequirePackage{luatexbase,luacode}
\begin{luacode}
+ local glyph_id = node.id "glyph"
+ local glue_id = node.id "glue"
+ local hlist_id = node.id "hlist"
local prevent_single_letter = function (head)
while head do
- if head.id == 37 then -- glyph
+ if head.id == glyph_id then -- glyph
if unicode.utf8.match(unicode.utf8.char(head.char),"%a") then -- some kind of letter
- if head.prev.id == 10 and head.next.id == 10 then -- only if we are at a one letter word
+ if head.prev.id == glue_id and head.next.id == glue_id then -- only if we are at a one letter word
local p = node.new("penalty")
p.penalty = 10000
@@ -104,10 +107,14 @@
\ifluatex
\RequirePackage{luatexbase,luacode}
\begin{luacode}
+ local glyph_id = node.id "glyph"
+ local glue_id = node.id "glue"
+ local hlist_id = node.id "hlist"
+
last_line_twice_parindent = function (head)
while head do
local _w,_h,_d = node.dimensions(head)
- if head.id == 10 and head.subtype ~= 15 and (_w < 2 * tex.parindent) then
+ if head.id == glue_id and head.subtype ~= 15 and (_w < 2 * tex.parindent) then
-- we are at a glue and have less then 2*\parindent to go
local p = node.new("penalty")
@@ -140,6 +147,10 @@
\ifluatex
\RequirePackage{luatexbase,luacode}
\begin{luacode}
+ local glyph_id = node.id "glyph"
+ local glue_id = node.id "glue"
+ local hlist_id = node.id "hlist"
+
compare_lines = function (line1,line2)
local head1 = line1.head
local head2 = line2.head
@@ -148,30 +159,30 @@
local word_count = 0
while head1 and head2 do
- if (head1.id == 37 and head2.id == 37
+ if (head1.id == glyph_id and head2.id == glyph_id
and head1.char == head2.char) -- identical glyph
- or (head1.id == 10 and head2.id == 10) then -- glue
+ or (head1.id == glue_id and head2.id == glue_id) then -- glue
- if head1.id == 37 then -- glyph
+ if head1.id == glyph_id then -- glyph
char_count = char_count + 1
- elseif char_count > 0 and head1.id == 10 then -- glue
+ elseif char_count > 0 and head1.id == glue_id then -- glue
word_count = word_count + 1
end
head1 = head1.next
head2 = head2.next
elseif (head1.id == 0 or head2.id == 0) then -- end of line
break
- elseif (head1.id ~= 37 and head1.id ~= 10) then -- some other kind of node
+ elseif (head1.id ~= glyph_id and head1.id ~= glue_id) then -- some other kind of node
head1 = head1.next
- elseif (head2.id ~= 37 and head2.id ~= 10) then -- some other kind of node
+ elseif (head2.id ~= glyph_id and head2.id ~= glue_id) then -- some other kind of node
head2 = head2.next
else -- no match, no special node
break
end
end
-- analyze last non-matching node, check for punctuation
- if ((head1 and head1.id == 37 and head1.char > 49)
- or (head2 and head2.id == 37 and head2.char > 49)) then
+ if ((head1 and head1.id == glyph_id and head1.char > 49)
+ or (head2 and head2.id == glyph_id and head2.char > 49)) then
-- not a word
elseif char_count > 0 then
word_count = word_count + 1
@@ -187,34 +198,34 @@
local word_count = 0
while head1 and head2 do
- if (head1.id == 37 and head2.id == 37
+ if (head1.id == glyph_id and head2.id == glyph_id
and head1.char == head2.char) -- identical glyph
- or (head1.id == 10 and head2.id == 10) then -- glue
+ or (head1.id == glue_id and head2.id == glue_id) then -- glue
- if head1.id == 37 then -- glyph
+ if head1.id == glyph_id then -- glyph
char_count = char_count + 1
- elseif char_count > 0 and head1.id == 10 then -- glue
+ elseif char_count > 0 and head1.id == glue_id then -- glue
word_count = word_count + 1
end
head1 = head1.prev
head2 = head2.prev
elseif (head1.id == 0 or head2.id == 0) then -- start of line
break
- elseif (head1.id ~= 37 and head1.id ~= 10) then -- some other kind of node
+ elseif (head1.id ~= glyph_id and head1.id ~= glue_id) then -- some other kind of node
head1 = head1.prev
- elseif (head2.id ~= 37 and head2.id ~= 10) then -- some other kind of node
+ elseif (head2.id ~= glyph_id and head2.id ~= glue_id) then -- some other kind of node
head2 = head2.prev
- elseif (head1.id == 37 and head1.char < 48) then -- punctuation
+ elseif (head1.id == glyph_id and head1.char < 48) then -- punctuation
head1 = head1.prev
- elseif (head2.id == 37 and head2.char < 48) then -- punctuation
+ elseif (head2.id == glyph_id and head2.char < 48) then -- punctuation
head2 = head2.prev
else -- no match, no special node
break
end
end
-- analyze last non-matching node, check for punctuation
- if ((head1 and head1.id == 37 and head1.char > 49)
- or (head2 and head2.id == 37 and head2.char > 49)) then
+ if ((head1 and head1.id == glyph_id and head1.char > 49)
+ or (head2 and head2.id == glyph_id and head2.char > 49)) then
-- not a word
elseif char_count > 0 then
word_count = word_count + 1
@@ -260,10 +271,10 @@
local max_word = tonumber(\inthomeoarchymaxwords)
while head do
- if head.id == 0 then -- new line
+ if head.id == hlist_id then -- new line
prev_line = cur_line
cur_line = head
- if prev_line.id == 0 then
+ if prev_line.id == hlist_id then
-- homeoarchy
char_count,word_count,prev_head,cur_head = compare_lines(prev_line,cur_line)
if char_count >= max_char or word_count >= max_word then
@@ -297,12 +308,12 @@
local linecounter = 0
while head do
- if head.id == 0 then -- new line
+ if head.id == hlist_id then -- new line
linecounter = linecounter + 1
if linecounter > 1 then
prev_line = cur_line
cur_line = head
- if prev_line.id == 0 then
+ if prev_line.id == hlist_id then
-- homoioteleuton
char_count,word_count,prev_head,cur_head = compare_lines_reverse(prev_line,cur_line)
if char_count >= max_char or word_count >= max_word then
@@ -338,11 +349,15 @@
\ifluatex
\RequirePackage{luatexbase,luacode}
\begin{luacode}
+local glyph_id = node.id "glyph"
+local glue_id = node.id "glue"
+local hlist_id = node.id "hlist"
+
river_analyze_line = function(line,dim1,dim2,precision)
local head = line.head
while head do
- if head.id == 10 then -- glue node
+ if head.id == glue_id then -- glue node
local w1,h1,d1 = node.dimensions(line.glue_set,line.glue_sign,line.glue_order,line.head,head.prev)
local w2,h2,d2 = node.dimensions(line.glue_set,line.glue_sign,line.glue_order,line.head,head)
--print("dim1:"..dim1.."; dim2:"..dim2.."; w1:"..w1.."; w2:"..w2)
@@ -368,7 +383,7 @@ rivers = function (head)
local linecounter = 0
while head do
- if head.id == 0 then -- new line
+ if head.id == hlist_id then -- new line
linecounter = linecounter + 1
prev_prev_line = prev_line
prev_line = cur_line
@@ -378,9 +393,9 @@ rivers = function (head)
char_count = 0
while cur_node do
- if cur_node.id == 37 then -- glyph
+ if cur_node.id == glyph_id then -- glyph
char_count = char_count + 1
- elseif cur_node.id == 10 and char_count > 0 and cur_node.next then -- glue node
+ elseif cur_node.id == glue_id and char_count > 0 and cur_node.next then -- glue node
-- prev_line
local w1,h1,d1 = node.dimensions(head.glue_set,head.glue_sign,head.glue_order,head.head,cur_node.prev)
local w2,h2,d2 = node.dimensions(head.glue_set,head.glue_sign,head.glue_order,head.head,cur_node)