summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/lua-typo
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 /Master/texmf-dist/tex/lualatex/lua-typo
parentd350cc52b8f25cb3c7d31afd4e89ef7ccdce79ed (diff)
lua-typo (11feb23)
git-svn-id: svn://tug.org/texlive/trunk@65795 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/lua-typo')
-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
2 files changed, 118 insertions, 74 deletions
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