summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/lua-typo
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-03-09 21:11:15 +0000
committerKarl Berry <karl@freefriends.org>2023-03-09 21:11:15 +0000
commit749499e349b826a6ad64e0ccd129eb88943df3d6 (patch)
tree3cf4ebe0fbf9c8981afda9f13f14ac4150e8c73d /Master/texmf-dist/tex/lualatex/lua-typo
parent9381aa71e9ff737ffdc887d13b2f428a6f8948d8 (diff)
lua-typo (9mar23)
git-svn-id: svn://tug.org/texlive/trunk@66495 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.cfg9
-rw-r--r--Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty432
2 files changed, 273 insertions, 168 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 9a3a27405a6..a3d826f54a5 100644
--- a/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.cfg
+++ b/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.cfg
@@ -23,6 +23,10 @@
\luatypoMinFull=3\relax
\luatypoMinPart=4\relax
+%% Minimum number of characters for the first word on a page if it ends
+%% a sentence.
+\luatypoMinLen=4\relax
+
%% Default colours = red, cyan, LTgrey
\definecolor{LTgrey}{gray}{0.6}
\definecolor{LTred}{rgb}{1,0.55,0}
@@ -40,11 +44,12 @@
\luatypoSetColor{11}{LTred} % Last word matches
\luatypoSetColor{12}{LTgrey}% Paragraph ending on a nearly full line
\luatypoSetColor{13}{cyan} % Footnote split
+\luatypoSetColor{14}{red} % Too short first (final) word on the page
%% Language specific settings (example for French):
%% short words (two letters max) to be avoided at end of lines.
-%%\luatypoOneChar{french}{'À Ô Y'}
-%%\luatypoTwoChars{french}{'Je Tu Il On Au De'}
+%%\luatypoOneChar{french}{"À Ô 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 fd7e4a1e5da..aa876b82fa9 100644
--- a/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty
+++ b/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty
@@ -11,10 +11,10 @@
%%
\NeedsTeXFormat{LaTeX2e}[2021/06/01]
\ProvidesPackage{lua-typo}
- [2023-02-10 v.0.61 Daniel Flipo]
+ [2023-03-08 v.0.65 Daniel Flipo]
\ifdefined\DeclareRelease
\DeclareRelease{v0.4}{2021-01-01}{lua-typo-2021-04-18.sty}
- \DeclareCurrentRelease{}{2023-02-04}
+ \DeclareCurrentRelease{}{2023-03-08}
\else
\PackageWarning{lua-typo}{Your LaTeX kernel is too old to provide
access\MessageBreak to former versions of the lua-typo package.%
@@ -37,6 +37,7 @@
\newcount\luatypoPageMin
\newcount\luatypoMinFull
\newcount\luatypoMinPart
+\newcount\luatypoMinLen
\newcount\luatypo@LANGno
\newcount\luatypo@options
\newtoks\luatypo@single
@@ -65,6 +66,7 @@ luatypo = { }
\DeclareBoolOption[false]{FirstWordMatch}
\DeclareBoolOption[false]{LastWordMatch}
\DeclareBoolOption[false]{FootnoteSplit}
+\DeclareBoolOption[false]{ShortFinalWord}
\AddToKeyvalOption{luatypo}{All}{%
\LT@ShortLinestrue \LT@ShortPagestrue
\LT@OverfullLinestrue \LT@UnderfullLinestrue
@@ -73,6 +75,7 @@ luatypo = { }
\LT@ParLastHyphentrue \LT@EOLShortWordstrue
\LT@FirstWordMatchtrue \LT@LastWordMatchtrue
\LT@BackParindenttrue \LT@FootnoteSplittrue
+ \LT@ShortFinalWordtrue
}
\ProcessKeyvalOptions{luatypo}
\AtEndOfPackage{%
@@ -165,6 +168,12 @@ luatypo = { }
\else
\directlua{ luatypo.FootnoteSplit = false }%
\fi
+ \ifLT@ShortFinalWord
+ \advance\luatypo@options by 1
+ \directlua{ luatypo.ShortFinalWord = true }%
+ \else
+ \directlua{ luatypo.ShortFinalWord = false }%
+ \fi
}
\ifLT@ShowOptions
\GenericWarning{* }{%
@@ -187,6 +196,7 @@ luatypo = { }
FirstWordMatch [false]\MessageBreak
LastWordMatch [false]\MessageBreak
FootnoteSplit [false]\MessageBreak
+ ShortFinalWord [false]\MessageBreak
\MessageBreak
*********************************************%
\MessageBreak Lua-typo [ShowOptions]
@@ -199,6 +209,7 @@ luatypo = { }
luatypo.Stretch = tex.count.luatypoStretchMax
luatypo.MinFull = tex.count.luatypoMinFull
luatypo.MinPart = tex.count.luatypoMinPart
+ luatypo.MinLen = tex.count.luatypoMinLen
luatypo.LLminWD = tex.dimen.luatypoLLminWD
luatypo.BackPI = tex.dimen.luatypoBackPI
luatypo.BackFuzz = tex.dimen.luatypoBackFuzz
@@ -243,7 +254,7 @@ luatypo = { }
local string = \the\luatypo@single
luatypo.single[langno] = " "
for p, c in utf8.codes(string) do
- local s = string.char(c)
+ local s = utf8.char(c)
luatypo.single[langno] = luatypo.single[langno] .. s
end
}%
@@ -260,7 +271,7 @@ luatypo = { }
local string = \the\luatypo@double
luatypo.double[langno] = " "
for p, c in utf8.codes(string) do
- local s = string.char(c)
+ local s = utf8.char(c)
luatypo.double[langno] = luatypo.double[langno] .. s
end
}%
@@ -291,14 +302,11 @@ char_to_discard[string.byte(":")] = true
char_to_discard[string.byte(";")] = true
char_to_discard[string.byte("-")] = true
-local split_lig = { }
-split_lig[0xFB00] = "ff"
-split_lig[0xFB01] = "fi"
-split_lig[0xFB02] = "fl"
-split_lig[0xFB03] = "ffi"
-split_lig[0xFB04] = "ffl"
-split_lig[0xFB05] = "st"
-split_lig[0xFB06] = "st"
+local eow_char = { }
+eow_char[string.byte(".")] = true
+eow_char[string.byte("!")] = true
+eow_char[string.byte("?")] = true
+eow_char[utf8.codepoint("…")] = true
local DISC = node.id("disc")
local GLYPH = node.id("glyph")
@@ -326,7 +334,6 @@ local USER = 0
local HYPH = 0x2D
local LIGA = 0x102
local parline = 0
-
local dimensions = node.dimensions
local rangedimensions = node.rangedimensions
local effective_glue = node.effective_glue
@@ -337,7 +344,18 @@ local traverse_id = node.traverse_id
local has_field = node.has_field
local uses_font = node.uses_font
local is_glyph = node.is_glyph
-
+local utf8_find = unicode.utf8.find
+local utf8_gsub = unicode.utf8.gsub
+local utf8_reverse = function (s)
+ if utf8.len(s) > 1 then
+ local so = ""
+ for p, c in utf8.codes(s) do
+ so = utf8.char(c) .. so
+ end
+ s = so
+ end
+ return s
+end
local color_node = function (node, color)
local attr = oberdiek.luacolor.getattribute()
if node and node.id == DISC then
@@ -419,61 +437,64 @@ local signature = function (node, string, swap)
local n = node
local str = string
if n and n.id == GLYPH then
- local b, id = is_glyph(n)
- if b and not char_to_discard[b] then
- if b == 0x2019 then b = 0x27 end
- if b < 0x100 then
- str = str .. string.char(b)
- elseif split_lig[b] then
- local c = split_lig[b]
- if swap then
- c = string.reverse(c)
- end
- str = str .. c
- elseif n.subtype == LIGA and b > 0xE000 then
- local c = string.sub(b,-2)
- if swap then
- c = string.reverse(c)
- end
- str = str .. c
- end
- end
+ local b = n.char
+ if b and not char_to_discard[b] then
+ if n.components then
+ local c = ""
+ for nn in traverse_id(GLYPH, n.components) do
+ c = c .. utf8.char(nn.char)
+ end
+ if swap then
+ str = str .. utf8_reverse(c)
+ else
+ str = str .. c
+ end
+ else
+ str = str .. utf8.char(b)
+ end
+ end
elseif n and n.id == DISC then
local pre = n.pre
local post = n.post
local c1 = ""
local c2 = ""
- if pre and pre.char and pre.char ~= HYPH and pre.char < 0x100 then
- c1 = string.char(pre.char)
+ if pre and pre.char then
+ if pre.components then
+ for nn in traverse_id(GLYPH, post.components) do
+ c1 = c1 .. utf8.char(nn.char)
+ end
+ else
+ c1 = utf8.char(pre.char)
+ end
+ c1 = utf8_gsub(c1, "-", "")
end
if post and post.char then
- if post.char < 0x100 then
- c2 = string.char(post.char)
- elseif split_lig[post.char] then
- c2 = split_lig[post.char]
- if swap then
- c2 = string.reverse(c2)
+ if post.components then
+ for nn in traverse_id(GLYPH, post.components) do
+ c2 = c2 .. utf8.char(nn.char)
end
+ else
+ c2 = utf8.char(post.char)
end
end
if swap then
- str = str .. c2 .. c1
+ str = str .. utf8_reverse(c2) .. c1
else
str = str .. c1 .. c2
end
end
- local len = string.len(str)
- if string.find(str, "_") then
+ local len = utf8.len(str)
+ if utf8_find(str, "_") then
len = len - 1
end
return len, str
end
-local check_last_word = function (old, node, line, colno, flag)
+local check_line_last_word = function (old, node, line, colno, flag)
local COLOR = luatypo.colortbl[11]
local match = false
local new = ""
local maxlen = 0
- if flag and node then
+ if node then
local swap = true
local box, go
local lastn = node
@@ -511,63 +532,80 @@ local check_last_word = function (old, node, line, colno, flag)
maxlen, new = signature (n, new, swap)
until not n or n.id == GLUE
end
- new = string.reverse(new)
- local MinFull = luatypo.MinFull
- local MinPart = luatypo.MinPart
- MinFull = math.min(MinPart,MinFull)
- local k = MinPart
- local oldlast = string.gsub (old, '.*_', '')
- local newlast = string.gsub (new, '.*_', '')
- local i = string.find(new, "_")
- if i and i > maxlen - MinPart + 1 then
- k = MinPart + 1
- end
- local oldsub = string.sub(old,-k)
- local newsub = string.sub(new,-k)
- local l = string.len(new)
- if oldsub == newsub and l >= k then
- match = true
- elseif oldlast == newlast and string.len(newlast) >= MinFull then
- match = true
- oldsub = oldlast
- newsub = newlast
- k = string.len(newlast)
- end
- if match then
- local osub = oldsub
- local nsub = newsub
- while osub == nsub and k <= maxlen do
- k = k +1
- osub = string.sub(old,-k)
- nsub = string.sub(new,-k)
- if osub == nsub then
- newsub = nsub
- end
+ new = utf8_reverse(new)
+ if flag then
+ local MinFull = luatypo.MinFull
+ local MinPart = luatypo.MinPart
+ MinFull = math.min(MinPart,MinFull)
+ local k = MinPart
+ local dlo = utf8_reverse(old)
+ local wen = utf8_reverse(new)
+ local oldlast = utf8_gsub (old, ".*_", "_")
+ local newlast = utf8_gsub (new, ".*_", "_")
+ local i
+ if utf8_find(newlast, "_") then
+ i = utf8.len(newlast)
end
- newsub = string.gsub(newsub, '^_', '')
- local msg = "E.O.L. MATCH=" .. newsub
- log_flaw(msg, line, colno, footnote)
- oldsub = string.reverse(newsub)
+ if i and i > maxlen - MinPart + 1 then
+ k = MinPart + 1
+ end
+ local oldsub = ""
local newsub = ""
- local n = lastn
- repeat
- if n and n.id ~= GLUE then
- color_node(n, COLOR)
- l, newsub = signature(n, newsub, swap)
- elseif n and n.id == GLUE then
- newsub = newsub .. "_"
- elseif not n and box then
- n = box
- else
- break
+ for p, c in utf8.codes(dlo) do
+ if utf8.len(oldsub) < k then
+ oldsub = utf8.char(c) .. oldsub
end
- n = n.prev
- until newsub == oldsub or l >= k
+ end
+ for p, c in utf8.codes(wen) do
+ if utf8.len(newsub) < k then
+ newsub = utf8.char(c) .. newsub
+ end
+ end
+ local l = utf8.len(new)
+ if oldsub == newsub and l >= k then
+ match = true
+ elseif oldlast == newlast and utf8.len(newlast) > MinFull then
+ match = true
+ oldsub = oldlast
+ newsub = newlast
+ k = utf8.len(newlast)
+ end
+ if match then
+ local osub = oldsub
+ local nsub = newsub
+ while osub == nsub and k <= maxlen do
+ k = k +1
+ osub = string.sub(old,-k)
+ nsub = string.sub(new,-k)
+ if osub == nsub then
+ newsub = nsub
+ end
+ end
+ newsub = utf8_gsub(newsub, "^_", "")
+ local msg = "E.O.L. MATCH=" .. newsub
+ log_flaw(msg, line, colno, footnote)
+ oldsub = utf8_reverse(newsub)
+ local newsub = ""
+ local n = lastn
+ repeat
+ if n and n.id ~= GLUE then
+ color_node(n, COLOR)
+ l, newsub = signature(n, newsub, swap)
+ elseif n and n.id == GLUE then
+ newsub = newsub .. "_"
+ elseif not n and box then
+ n = box
+ else
+ break
+ end
+ n = n.prev
+ until newsub == oldsub or l >= k
+ end
end
end
return new, match
end
-local check_first_word = function (old, node, line, colno, flag)
+local check_line_first_word = function (old, node, line, colno, flag)
local COLOR = luatypo.colortbl[10]
local match = false
local swap = false
@@ -613,24 +651,31 @@ local check_first_word = function (old, node, line, colno, flag)
local MinPart = luatypo.MinPart
MinFull = math.min(MinPart,MinFull)
local k = MinPart
- local oldsub = ""
- local newsub = ""
- local oldfirst = string.gsub (old, '_.*', '')
- local newfirst = string.gsub (new, '_.*', '')
- local i = string.find(new, "_")
+ local oldfirst = utf8_gsub (old, "_.*", "_")
+ local newfirst = utf8_gsub (new, "_.*", "_")
+ local i
+ if utf8_find(newfirst, "_") then
+ i = utf8.len(newfirst)
+ end
if i and i <= MinPart then
k = MinPart + 1
end
- local oldsub = string.sub(old,1,k)
- local newsub = string.sub(new,1,k)
- local l = string.len(newsub)
+ local oldsub = ""
+ local newsub = ""
+ for p, c in utf8.codes(old) do
+ if utf8.len(oldsub) < k then oldsub = oldsub .. utf8.char(c) end
+ end
+ for p, c in utf8.codes(new) do
+ if utf8.len(newsub) < k then newsub = newsub .. utf8.char(c) end
+ end
+ local l = utf8.len(newsub)
if oldsub == newsub and l >= k then
match = true
- elseif oldfirst == newfirst and string.len(newfirst) >= MinFull then
+ elseif oldfirst == newfirst and utf8.len(newfirst) > MinFull then
match = true
oldsub = oldfirst
newsub = newfirst
- k = string.len(newfirst)
+ k = utf8.len(newfirst)
end
if match then
local osub = oldsub
@@ -643,12 +688,12 @@ local check_first_word = function (old, node, line, colno, flag)
newsub = nsub
end
end
- newsub = string.gsub(newsub, '_$', '') --$
+ newsub = utf8_gsub(newsub, "_$", "") --$
local msg = "B.O.L. MATCH=" .. newsub
log_flaw(msg, line, colno, footnote)
oldsub = newsub
local newsub = ""
- local k = string.len(oldsub)
+ local k = utf8.len(oldsub)
local n = start
repeat
if n and n.id ~= GLUE then
@@ -667,6 +712,54 @@ local check_first_word = function (old, node, line, colno, flag)
end
return new, match
end
+local check_page_first_word = function (node, colno)
+ local COLOR = luatypo.colortbl[14]
+ local match = false
+ local swap = false
+ local new = ""
+ local maxlen = luatypo.MinLen
+ local len = 0
+ local n = node
+ local pn
+ while n and n.id ~= GLYPH and n.id ~= DISC and
+ (n.id ~= HLIST or n.subtype == INDENT) do
+ n = n.next
+ end
+ local start = n
+ if n and n.id == HLIST then
+ start = n.head
+ n = n.head
+ end
+ repeat
+ len, new = signature (n, new, swap)
+ n = n.next
+ until len > maxlen or (n and n.id == GLYPH and eow_char[n.char]) or
+ (n and n.id == GLUE) or
+ (n and n.id == KERN and n.subtype == 1)
+ if n and (n.id == GLUE or n.id == KERN) then
+ pn = n
+ n = n.next
+ end
+ if len <= maxlen and n and n.id == GLYPH and eow_char[n.char] then
+ match =true
+ if pn and (pn.id == GLUE or pn.id == KERN) then
+ new = new .. " "
+ len = len + 1
+ end
+ len = len + 1
+ end
+ if match then
+ local msg = "ShortFinalWord=" .. new
+ log_flaw(msg, 1, colno, false)
+ local n = start
+ repeat
+ color_node(n, COLOR)
+ n = n.next
+ until eow_char[n.char]
+ color_node(n, COLOR)
+ end
+ return match
+end
local check_regexpr = function (glyph, line, colno)
local COLOR = luatypo.colortbl[3]
local lang = glyph.lang
@@ -675,11 +768,11 @@ local check_regexpr = function (glyph, line, colno)
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 lchar and previous and previous.id == GLUE then
+ match = utf8_find(luatypo.single[lang], utf8.char(lchar))
if match then
retflag = true
- local msg = "RGX MATCH=" .. string.char(lchar)
+ local msg = "RGX MATCH=" .. utf8.char(lchar)
log_flaw(msg, line, colno, footnote)
color_node(glyph,COLOR)
end
@@ -689,9 +782,9 @@ local check_regexpr = function (glyph, line, colno)
if lchar and previous and previous.id == GLYPH then
local pchar, id = is_glyph(previous)
local pprev = previous.prev
- if pchar and pchar < 0x100 and pprev and pprev.id == GLUE then
- local pattern = string.char(pchar) .. string.char(lchar)
- match = string.find(luatypo.double[lang], pattern)
+ if pchar and pprev and pprev.id == GLUE then
+ local pattern = utf8.char(pchar) .. utf8.char(lchar)
+ match = utf8_find(luatypo.double[lang], pattern)
if match then
retflag = true
local msg = "RGX MATCH=" .. pattern
@@ -705,10 +798,9 @@ local check_regexpr = function (glyph, line, colno)
if pprev and pprev.id == GLYPH then
local pchar, id = is_glyph(pprev)
local ppprev = pprev.prev
- if pchar and pchar < 0x100 and
- ppprev and ppprev.id == GLUE then
- local pattern = string.char(pchar) .. string.char(lchar)
- match = string.find(luatypo.double[lang], pattern)
+ if pchar and ppprev and ppprev.id == GLUE then
+ local pattern = utf8.char(pchar) .. utf8.char(lchar)
+ match = utf8_find(luatypo.double[lang], pattern)
if match then
retflag = true
local msg = "REGEXP MATCH=" .. pattern
@@ -776,7 +868,7 @@ local get_pagebody = function (head)
end
end
if not body then
- texio.write_nl('***lua-typo ERROR: PAGE BODY *NOT* FOUND!***')
+ texio.write_nl("***lua-typo ERROR: PAGE BODY *NOT* FOUND!***")
end
return body
end
@@ -800,6 +892,7 @@ check_vtop = function (head, colno, vpos)
local EOLShortWords = luatypo.EOLShortWords
local LastWordMatch = luatypo.LastWordMatch
local FootnoteSplit = luatypo.FootnoteSplit
+ local ShortFinalWord = luatypo.ShortFinalWord
local Stretch = math.max(luatypo.Stretch/100,1)
local blskip = tex.getglue("baselineskip")
local vpos_min = PAGEmin * blskip
@@ -828,6 +921,7 @@ check_vtop = function (head, colno, vpos)
vpos = vpos + head.height + head.depth
local linewd = head.width
local first = head.head
+ local ListItem = false
if footnote then
ftnline = ftnline + 1
line = ftnline
@@ -871,9 +965,10 @@ check_vtop = function (head, colno, vpos)
(first.id == GLUE and first.subtype == LFTSKIP) do
first = first.next
end
- local ListItem = false
if first.id == LPAR then
hyphcount = 0
+ firstwd = ""
+ lastwd = ""
if not footnote then
parline = 1
if body_bottom then
@@ -930,7 +1025,7 @@ check_vtop = function (head, colno, vpos)
if FirstWordMatch then
local flag = not ListItem
firstwd, flag =
- check_first_word(firstwd, first, line, colno, flag)
+ check_line_first_word(firstwd, first, line, colno, flag)
if flag then
pageflag = true
end
@@ -941,46 +1036,46 @@ check_vtop = function (head, colno, vpos)
flag = false
end
lastwd, flag =
- check_last_word(lastwd, pn, line, colno, flag)
+ check_line_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 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)
+ check_line_first_word(firstwd, first, line, colno, flag)
if flag then
pageflag = true
end
end
if LastWordMatch then
- local flag = false
+ local flag = true
lastwd, flag =
- check_last_word(lastwd, ln, line, colno, true)
+ check_line_last_word(lastwd, ln, line, colno, flag)
if flag then
pageflag = true
end
@@ -1009,32 +1104,32 @@ check_vtop = function (head, colno, vpos)
end
else
hyphcount = 0
- 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 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 FirstWordMatch then
local flag = not ListItem
firstwd, flag =
- check_first_word(firstwd, first, line, colno, flag)
+ check_line_first_word(firstwd, first, line, colno, flag)
if flag then
pageflag = true
end
end
if LastWordMatch and pn then
- local flag
+ local flag = true
lastwd, flag =
- check_last_word(lastwd, pn, line, colno, true)
+ check_line_last_word(lastwd, pn, line, colno, flag)
if flag then
pageflag = true
end
@@ -1050,6 +1145,10 @@ check_vtop = function (head, colno, vpos)
end
end
end
+ if ShortFinalWord and pageline == 1 and parline > 1 and
+ check_page_first_word(first,colno) then
+ pageflag = true
+ end
elseif head.id == HLIST and
(head.subtype == EQN or head.subtype == ALIGN) and
(head.height > 0 or head.depth > 0) then
@@ -1209,10 +1308,9 @@ return luatypo.check_page
end
}%
}
-
\InputIfFileExists{lua-typo.cfg}%
- {\PackageInfo{lua-typo.sty}{'lua-typo.cfg' file loaded}}%
- {\PackageInfo{lua-typo.sty}{'lua-typo.cfg' file not found.
+ {\PackageInfo{lua-typo.sty}{"lua-typo.cfg" file loaded}}%
+ {\PackageInfo{lua-typo.sty}{"lua-typo.cfg" file not found.
\MessageBreak Providing default values.}%
\definecolor{LTgrey}{gray}{0.6}%
\definecolor{LTred}{rgb}{1,0.55,0}
@@ -1230,6 +1328,7 @@ return luatypo.check_page
\luatypoSetColor{11}{LTred}% Last word matches
\luatypoSetColor{12}{LTgrey}% Paragraph ending on a nearly full line
\luatypoSetColor{13}{cyan}% Footnote split
+ \luatypoSetColor{14}{red}% Too short first (final) word on the page
\luatypoBackPI=1em\relax
\luatypoBackFuzz=2pt\relax
\ifdim\parindent=0pt \luatypoLLminWD=20pt\relax
@@ -1239,6 +1338,7 @@ return luatypo.check_page
\luatypoPageMin=5\relax
\luatypoMinFull=4\relax
\luatypoMinPART=4\relax
+ \luatypoMinLen=4\relax
}%
%%
%%