summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/page-mix.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2019-12-17 17:22:50 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2019-12-17 17:22:50 +0100
commitd1f4da02201fd33c139ee1756296e8df53580ff7 (patch)
treed24fad194af62020481cac8d2041913a36789e8a /tex/context/base/mkiv/page-mix.lua
parent37cca59f16fc3ab5bf3ce19fd94161d1c2f6ffdc (diff)
downloadcontext-d1f4da02201fd33c139ee1756296e8df53580ff7.tar.gz
2019-12-17 16:25:00
Diffstat (limited to 'tex/context/base/mkiv/page-mix.lua')
-rw-r--r--tex/context/base/mkiv/page-mix.lua94
1 files changed, 49 insertions, 45 deletions
diff --git a/tex/context/base/mkiv/page-mix.lua b/tex/context/base/mkiv/page-mix.lua
index d64646d8a..dacc829d7 100644
--- a/tex/context/base/mkiv/page-mix.lua
+++ b/tex/context/base/mkiv/page-mix.lua
@@ -349,49 +349,50 @@ local function preparesplit(specification) -- a rather large function
lastcontent = nil
end
- -- local function backtrack(start)
- -- local current = start
- -- -- first skip over glue and penalty
- -- while current do
- -- local id = getid(current)
- -- if id == glue_code then
- -- if trace_state then
- -- report_state("backtracking over %s in column %s, value %p","glue",column,getwidth(current))
- -- end
- -- current = getprev(current)
- -- elseif id == penalty_code then
- -- if trace_state then
- -- report_state("backtracking over %s in column %s, value %i","penalty",column,getpenalty(current))
- -- end
- -- else
- -- break
- -- end
- -- end
- -- -- then skip over content
- -- while current do
- -- local id = getid(current)
- -- if id == glue_code then
- -- if trace_state then
- -- report_state("quitting at %s in column %s, value %p","glue",column,getwidth(current))
- -- end
- -- break
- -- elseif id == penalty_code then
- -- if trace_state then
- -- report_state("quitting at %s in column %s, value %i","penalty",column,getpenalty(current))
- -- end
- -- break
- -- else
- -- current = getprev(current)
- -- end
- -- end
- -- if not current then
- -- if trace_state then
- -- report_state("no effective backtracking in column %s",column)
- -- end
- -- current = start
- -- end
- -- return current
- -- end
+ local function backtrack(start)
+ local current = start
+ -- first skip over glue and penalty
+ while current do
+ local id = getid(current)
+ if id == glue_code then
+ if trace_state then
+ report_state("backtracking over %s in column %s, value %p","glue",column,getwidth(current))
+ end
+ current = getprev(current)
+ elseif id == penalty_code then
+ if trace_state then
+ report_state("backtracking over %s in column %s, value %i","penalty",column,getpenalty(current))
+ end
+ current = getprev(current)
+ else
+ break
+ end
+ end
+ -- then skip over content
+ while current do
+ local id = getid(current)
+ if id == glue_code then
+ if trace_state then
+ report_state("quitting at %s in column %s, value %p","glue",column,getwidth(current))
+ end
+ break
+ elseif id == penalty_code then
+ if trace_state then
+ report_state("quitting at %s in column %s, value %i","penalty",column,getpenalty(current))
+ end
+ break
+ else
+ current = getprev(current)
+ end
+ end
+ if not current then
+ if trace_state then
+ report_state("no effective backtracking in column %s",column)
+ end
+ current = start
+ end
+ return current
+ end
local function gotonext()
if lastcurrent then
@@ -400,8 +401,11 @@ local function preparesplit(specification) -- a rather large function
report_state("backtracking to preferred break in column %s",column)
end
-- todo: also remember height/depth
- -- current = backtrack(lastcurrent) -- not ok, we go to far back so why was this needed
- current = lastcurrent
+ if true then -- todo: option to disable this
+ current = backtrack(lastcurrent) -- not ok yet
+ else
+ current = lastcurrent
+ end
backtracked = true
end
lastcurrent = nil