summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-02-04 21:14:15 +0000
committerKarl Berry <karl@freefriends.org>2023-02-04 21:14:15 +0000
commit18270d5b800b9c4f6e47613bef99e5a27812ea54 (patch)
tree077bf2ca98d93073edb3e183682594b9b4dbbf4f /Master/texmf-dist/tex/lualatex
parentec2a659e3c578cec9614366d3c839c4df6f3abc6 (diff)
lua-typo (4feb23)
git-svn-id: svn://tug.org/texlive/trunk@65734 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex')
-rw-r--r--Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty234
1 files changed, 131 insertions, 103 deletions
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 5110fb0e605..4d64e57f297 100644
--- a/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty
+++ b/Master/texmf-dist/tex/lualatex/lua-typo/lua-typo.sty
@@ -9,14 +9,15 @@
%% IMPORTANT NOTICE:
%% For the copyright see the source file `lua-typo.dtx’.
%%
+\NeedsTeXFormat{LaTeX2e}[2021/06/01]
\ProvidesPackage{lua-typo}
- [2021/05/13 v.0.50 Daniel Flipo]
+ [2023-02-04 v.0.60 Daniel Flipo]
\ifdefined\DeclareRelease
\DeclareRelease{v0.4}{2021-01-01}{lua-typo-2021-04-18.sty}
- \DeclareCurrentRelease{}{2021-05-13}
+ \DeclareCurrentRelease{}{2023-02-04}
\else
\PackageWarning{lua-typo}{Your LaTeX kernel is too old to provide
- access\MessageBreak to former versions of the lettrine package.%
+ access\MessageBreak to former versions of the lua-typo package.%
\MessageBreak Anyway, lua-typo requires a LaTeX kernel dated%
\MessageBreak 2020-01-01 or newer; reported}
\fi
@@ -218,11 +219,11 @@ luatypo = { }
\directlua{
texio.write_nl(' ')
texio.write_nl('*************************************')
- if luatypo.pagelist == "" then
+ if luatypo.pagelist == " " then
texio.write_nl('*** lua-typo: No Typo Flaws found.')
else
texio.write_nl('*** lua-typo: WARNING *************')
- texio.write_nl('The following pages need attention: ')
+ texio.write_nl('The following pages need attention:')
texio.write(luatypo.pagelist)
end
texio.write_nl('***********************************')
@@ -277,7 +278,7 @@ luatypo = { }
luatypo.single = { }
luatypo.double = { }
luatypo.colortbl = { }
-luatypo.pagelist = ""
+luatypo.pagelist = " "
luatypo.buffer = "List of typographic flaws found for "
.. tex.jobname .. ".tex:\string\n\string\n"
@@ -730,6 +731,29 @@ local show_pre_disc = function (disc, color)
end
return n
end
+local footnoterule_ahead = function (head)
+ local n = head
+ local flag = false
+ local totalht, ruleht, ht1, ht2, ht3
+ if n and n.id == KERN and n.subtype == 1 then
+ totalht = n.kern
+ n = n.next
+ while n and n.id == GLUE do n = n.next end
+ if n and n.id == RULE and n.subtype == 0 then
+ ruleht = n.height
+ totalht = totalht + ruleht
+ n = n.next
+ if n and n.id == KERN and n.subtype == 1 then
+ totalht = totalht + n.kern
+ if totalht == 0 or totalht == ruleht then
+ flag = true
+ else
+ end
+ end
+ end
+ end
+ return flag
+end
local get_pagebody = function (head)
local textht = tex.getdimen("textheight")
local fn = head.list
@@ -757,27 +781,7 @@ local get_pagebody = function (head)
end
return body
end
-local footnoterule_ahead = function (head, debug)
- local n = head
- local flag = false
- if n and n.id == KERN and n.subtype == 1 then
- local htr = n.kern
- local ht1, ht2, ht3
- n = n.next
- if n and n.id == RULE and n.subtype == 0 then
- htr = htr + n.height
- n = n.next
- if n and n.id == KERN and n.subtype == 1 then
- htr = htr + n.kern
- if htr == 0 then
- flag = true
- end
- end
- end
- end
- return flag
-end
-check_vtop = function (head, colno)
+check_vtop = function (head, colno, vpos)
local PAGEmin = luatypo.PAGEmin
local HYPHmax = luatypo.HYPHmax
local LLminWD = luatypo.LLminWD
@@ -799,13 +803,9 @@ check_vtop = function (head, colno)
local FootnoteSplit = luatypo.FootnoteSplit
local Stretch = math.max(luatypo.Stretch/100,1)
local blskip = tex.getglue("baselineskip")
- local pageno = tex.getcount("c@page")
local vpos_min = PAGEmin * blskip
vpos_min = vpos_min * 1.5
- local vpos = 0
- local pageflag = false
- local body_bottom = false
- local page_bottom = false
+ local linewd = tex.getdimen("textwidth")
local first_bot = true
local footnote = false
local ftnsplit = false
@@ -819,23 +819,18 @@ check_vtop = function (head, colno)
local pageline = 0
local ftnline = 0
local line = 0
+ 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 not footnote and head.id == KERN and head.subtype == 1 then
- if footnoterule_ahead(head, true) then
- footnote = true
- ftnline = 0
- body_bottom = false
- orphanflag = false
- lwhyphflag = false
- hyphcount = 0
- firstwd = ""
- lastwd = ""
- else
- vpos = vpos + head.kern
- end
- elseif head.id == HLIST and head.subtype == LINE and
+ 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
if footnote then
ftnline = ftnline + 1
line = ftnline
@@ -843,8 +838,19 @@ check_vtop = function (head, colno)
pageline = pageline + 1
line = pageline
end
+ local n = nextnode
+ while n and (n.id == GLUE or n.id == PENALTY or
+ n.id == WHATSIT ) do
+ n = n.next
+ end
+ if not n then
+ page_bottom = true
+ body_bottom = true
+ elseif footnoterule_ahead(n) then
+ body_bottom = true
+ end
local first = head.head
- local hmax = head.width + tex.hfuzz
+ local hmax = linewd + tex.hfuzz
local w,h,d = dimensions(1,2,0, first)
if w > hmax and OverfullLines then
pageflag = true
@@ -862,22 +868,6 @@ check_vtop = function (head, colno)
local COLOR = luatypo.colortbl[8]
color_line (head, COLOR)
end
- vpos = vpos + head.height + head.depth
- local n = head.next
- while n and
- (n.id == GLUE or n.id == PENALTY or n.id == WHATSIT) do
- n = n.next
- end
- if not n then
- if footnote then
- page_bottom = true
- else
- page_bottom = true
- body_bottom = true
- end
- elseif footnoterule_ahead(n, false) then
- body_bottom = true
- end
if footnote and page_bottom then
ftnsplit = true
end
@@ -890,9 +880,9 @@ check_vtop = function (head, colno)
hyphcount = 0
if not footnote then
parline = 1
- end
- if body_bottom then
- orphanflag = true
+ if body_bottom then
+ orphanflag = true
+ end
end
local nn = first.next
if nn and nn.id == HLIST and nn.subtype == BOX then
@@ -916,7 +906,7 @@ check_vtop = function (head, colno)
end
local PFskip = effective_glue(pn,head)
if ShortLines then
- local llwd = tex.hsize - PFskip
+ local llwd = linewd - PFskip
if llwd < LLminWD then
pageflag = true
local msg = "SHORT LINE: " ..
@@ -1059,19 +1049,19 @@ check_vtop = function (head, colno)
color_line (head, COLOR)
end
end
- local n = head.next
- while n and (n.id == GLUE or n.id == PENALTY or
- n.id == WHATSIT or n.id == VLIST) do
- n = n.next
- end
- if not n then
- page_bottom = true
- body_bottom = true
- elseif footnoterule_ahead(n, false) then
- body_bottom = true
- end
- elseif head.id == VLIST then
+ elseif head and head.id == RULE and head.subtype == 0 then
vpos = vpos + head.height + head.depth
+ if body_bottom then
+ footnote = true
+ ftnline = 0
+ body_bottom = false
+ ftnrule_ahead = false
+ orphanflag = false
+ lwhyphflag = false
+ hyphcount = 0
+ firstwd = ""
+ lastwd = ""
+ end
elseif body_bottom and head.id == GLUE and head.subtype == 0 then
if first_bot then
if pageline > 1 and pageline < PAGEmin and ShortPages then
@@ -1092,38 +1082,76 @@ check_vtop = function (head, colno)
end
elseif head.id == GLUE then
vpos = vpos + effective_glue(head,body)
+ elseif head.id == KERN and head.subtype == 1 then
+ vpos = vpos + head.kern
+ elseif head.id == VLIST then
+ vpos = vpos + head.height + head.depth
+ elseif head.id == HLIST and head.subtype == BOX then
+ local hf = head.list
+ if hf and hf.id == VLIST and hf.subtype == 0 then
+ break
+ end
end
head = nextnode
end
- return pageflag
+ if pageflag then
+ if not lastp or pageno > lastp then
+ luatypo.pagelist = luatypo.pagelist .. tostring(pageno) .. ", "
+ end
+ end
+ return head
end
luatypo.check_page = function (head)
- local pageno = tex.getcount("c@page")
- local pageflag = false
+ local textwd = tex.getdimen("textwidth")
+ local vpos = 0
local n2, n3, col, colno
local body = get_pagebody(head)
+ local footnote = false
+ local top = body
local first = body.list
- if first.id == HLIST and first.subtype == 2 then
- n2 = first.list
- colno = 0
- for n in traverse_id(HLIST, n2) do
- if n.id == HLIST and n.subtype == 2 then
- n3 = n.list
- col = n3.list
- colno = colno + 1
- pageflag = check_vtop(col,colno)
- end
- end
- elseif body.id == VLIST and body.subtype == 0 then
- col = body.list
- pageflag = check_vtop(col,colno)
+ if (first and first.id == HLIST and first.subtype == BOX) or
+ (first and first.id == VLIST and first.subtype == 0) then
+ top = body.list
+ first = top.list
end
- if pageflag then
- local pl = luatypo.pagelist
- local p = tonumber(string.match(pl, "%s(%d+),%s$"))
- if not p or pageno > p then
- luatypo.pagelist = luatypo.pagelist .. tostring(pageno) .. ", "
- end
+ while top do
+ first = top.list
+ if top and top.id == VLIST and top.subtype == 0 and
+ top.width > textwd/2 then
+ local next = check_vtop(first,colno,vpos)
+ if next then
+ top = next
+ elseif top then
+ top = top.next
+ end
+ elseif (top and top.id == HLIST and top.subtype == BOX) and
+ (first and first.id == VLIST and first.subtype == 0) and
+ (first.height > 0 and first.width > 0) then
+ colno = 0
+ for n in traverse_id(VLIST, first) do
+ colno = colno + 1
+ col = n.list
+ check_vtop(col,colno,vpos)
+ end
+ colno = nil
+ top = top.next
+ elseif (top and top.id == HLIST and top.subtype == BOX) and
+ (first and first.id == HLIST and first.subtype == BOX) and
+ (first.height > 0 and first.width > 0) then
+ colno = 0
+ for n in traverse_id(HLIST, first) do
+ colno = colno + 1
+ local nn = n.list
+ if nn and nn.list then
+ col = nn.list
+ check_vtop(col,colno,vpos)
+ end
+ end
+ colno = nil
+ top = top.next
+ else
+ top = top.next
+ end
end
return true
end
@@ -1135,7 +1163,7 @@ return luatypo.check_page
luatexbase.add_to_callback
("pre_shipout_filter",luatypo.check_page,"check_page",1)
end
- }
+ }%
}
\InputIfFileExists{lua-typo.cfg}%