summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/spac-ver.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-07-26 21:34:14 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2018-07-26 21:34:14 +0200
commit1add40ac787d36d3bd40e196aea752dff2cfb769 (patch)
treec109f4b7a8a69de8071b6f937954ab06a4de26de /tex/context/base/mkiv/spac-ver.lua
parent669436bb34437aee17f1823836cbbb16c570a505 (diff)
downloadcontext-1add40ac787d36d3bd40e196aea752dff2cfb769.tar.gz
2018-07-26 20:48:00
Diffstat (limited to 'tex/context/base/mkiv/spac-ver.lua')
-rw-r--r--tex/context/base/mkiv/spac-ver.lua111
1 files changed, 64 insertions, 47 deletions
diff --git a/tex/context/base/mkiv/spac-ver.lua b/tex/context/base/mkiv/spac-ver.lua
index 06b05f5e0..aae9913f7 100644
--- a/tex/context/base/mkiv/spac-ver.lua
+++ b/tex/context/base/mkiv/spac-ver.lua
@@ -2040,65 +2040,82 @@ do
local ignoredepth = -65536000
- function vspacing.synchronizepage()
+ -- A previous version analyzed the number of lines moved to the next page in
+ -- synchronizepage because prevgraf is unreliable in that case. However, we cannot
+ -- tweak that parameter because it is also used in postlinebreak and hangafter, so
+ -- there is a danger for interference. Therefore we now do it dynamically.
+
+ -- We can also support other lists but there prevgraf probably is ok.
+
+ function vspacing.getnofpreviouslines(head)
if enabled then
- local newdepth = outer.prevdepth
- local olddepth = newdepth
- local oldlines = outer.prevgraf
- local newlines = 0
- local head = texlists.page_head
+ if not thead then
+ head = texlists.page_head
+ end
+ local noflines = 0
if head then
- head = tonut(head)
- if getid(head) == glue_code and getsubtype(head) == topskip_code then
- local tail = find_node_tail(head)
- while tail do
- local id = getid(tail)
- if id == hlist_code then
- if getsubtype(tail) == line_code then
- newlines = newlines + 1
- else
- break
- end
- elseif id == vlist_code then
+ local tail = find_node_tail(tonut(head))
+ while tail do
+ local id = getid(tail)
+ if id == hlist_code then
+ if getsubtype(tail) == line_code then
+ noflines = noflines + 1
+ else
break
- elseif id == glue_code then
- local subtype = getsubtype(tail)
- if subtype == baselineskip_code or subtype == lineskip_code then
- -- we're ok
- elseif subtype == parskip_code then
- if getwidth(tail) > 0 then
- break
- else
- -- we assume we're ok
- end
+ end
+ elseif id == vlist_code then
+ break
+ elseif id == glue_code then
+ local subtype = getsubtype(tail)
+ if subtype == baselineskip_code or subtype == lineskip_code then
+ -- we're ok
+ elseif subtype == parskip_code then
+ if getwidth(tail) > 0 then
+ break
+ else
+ -- we assume we're ok
end
- elseif id == penalty_code then
- -- we're probably ok
- elseif id == rule_code or id == kern_code then
- break
- else
- -- ins, mark, boundary, whatsit
end
- tail = getprev(tail)
+ elseif id == penalty_code then
+ -- we're probably ok
+ elseif id == rule_code or id == kern_code then
+ break
+ else
+ -- ins, mark, boundary, whatsit
end
+ tail = getprev(tail)
end
- else
- newdepth = ignoredepth
- texset("prevdepth",ignoredepth)
- outer.prevdepth = ignoredepth
- end
- texset("prevgraf", newlines)
- outer.prevgraf = newlines
- if trace then
- report("page %i, prevdepth %p => %p, prevgraf %i => %i",
- texgetcount("realpageno"),olddepth,newdepth,oldlines,newlines)
- report("list %s",nodes.idsandsubtypes(head))
end
+ return noflines
end
end
+ interfaces.implement {
+ name = "getnofpreviouslines",
+ public = true,
+ actions = vspacing.getnofpreviouslines,
+ }
-
+ function vspacing.synchronizepage()
+ if enabled then
+ if trace then
+ local newdepth = outer.prevdepth
+ local olddepth = newdepth
+ if not texlists.page_head then
+ newdepth = ignoredepth
+ texset("prevdepth",ignoredepth)
+ outer.prevdepth = ignoredepth
+ end
+ report("page %i, prevdepth %p => %p",texgetcount("realpageno"),olddepth,newdepth)
+ -- report("list %s",nodes.idsandsubtypes(head))
+ else
+ if not texlists.page_head then
+ texset("prevdepth",ignoredepth)
+ outer.prevdepth = ignoredepth
+ end
+ end
+ end
+ end
local trace = false