summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/anch-pos.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-02-20 15:53:16 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-02-20 15:53:16 +0100
commit7ddc6c5aec02c5802944772975133733dc0e7440 (patch)
tree584f033bef72a8ab4b1e2174c3b2eadef1940494 /tex/context/base/mkiv/anch-pos.lua
parentb5ef32a9a6a99e134e669b702e89a55fbabf5306 (diff)
downloadcontext-7ddc6c5aec02c5802944772975133733dc0e7440.tar.gz
2017-02-20 15:15:00
Diffstat (limited to 'tex/context/base/mkiv/anch-pos.lua')
-rw-r--r--tex/context/base/mkiv/anch-pos.lua49
1 files changed, 48 insertions, 1 deletions
diff --git a/tex/context/base/mkiv/anch-pos.lua b/tex/context/base/mkiv/anch-pos.lua
index 848b42d41..6a9612d9e 100644
--- a/tex/context/base/mkiv/anch-pos.lua
+++ b/tex/context/base/mkiv/anch-pos.lua
@@ -269,7 +269,54 @@ end
-- function jobpositions.getcollected(class,tag) if tag then return collected[class..tag] else return collected[class] end end
-- function jobpositions.gettobesaved(class,tag) if tag then return tobesaved[class..tag] else return tobesaved[class] end end
-job.register('job.positions.collected', tobesaved, initializer)
+local function finalizer()
+ -- We make the (possible extensive) shape lists sparse working
+ -- from the end. We could also drop entries here that have l and
+ -- r the same which saves testing later on.
+ for k, v in next, tobesaved do
+ local s = v.s
+ if s then
+ for p, data in next, s do
+ local n = #data
+ if n > 1 then
+ local ph = data[1][2]
+ local pd = data[1][3]
+ local xl = data[1][4]
+ local xr = data[1][5]
+ for i=2,n do
+ local di = data[i]
+ local h = di[2]
+ local d = di[3]
+ local l = di[4]
+ local r = di[5]
+ if r == xr then
+ di[5] = nil
+ if l == xl then
+ di[4] = nil
+ if d == pd then
+ di[3] = nil
+ if h == ph then
+ di[2] = nil
+ else
+ ph = h
+ end
+ else
+ pd, ph = d, h
+ end
+ else
+ ph, pd, xl = h, d, l
+ end
+ else
+ ph, pd, xl, xr = h, d, l, r
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+job.register('job.positions.collected', tobesaved, initializer, finalizer)
local regions = { }
local nofregions = 0