summaryrefslogtreecommitdiff
path: root/tex/context/base/strc-mar.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/strc-mar.lua')
-rw-r--r--tex/context/base/strc-mar.lua79
1 files changed, 44 insertions, 35 deletions
diff --git a/tex/context/base/strc-mar.lua b/tex/context/base/strc-mar.lua
index 02d676fb9..b3a6e8f35 100644
--- a/tex/context/base/strc-mar.lua
+++ b/tex/context/base/strc-mar.lua
@@ -19,13 +19,12 @@ local commands = commands
local allocate = utilities.storage.allocate
local setmetatableindex = table.setmetatableindex
+local traversenodes = nodes.traverse
local nodecodes = nodes.nodecodes
local glyph_code = nodecodes.glyph
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
-local traversenodes = nodes.traverse
-
local texsetattribute = tex.setattribute
local texgetbox = tex.getbox
@@ -66,6 +65,10 @@ local lists = structures.lists
local settings_to_array = utilities.parsers.settings_to_array
+local boxes_too = false -- at some point we can also tag boxes or use a zero char
+
+directives.register("marks.boxestoo", function(v) boxes_too = v end)
+
marks.data = marks.data or allocate()
storage.register("structures/marks/data", marks.data, "structures.marks.data")
@@ -114,13 +117,15 @@ local function sweep(head,first,last)
last = a
end
elseif id == hlist_code or id == vlist_code then
- local a = n[a_marks]
- if not a then
- -- next
- elseif first == 0 then
- first, last = a, a
- elseif a > last then
- last = a
+ if boxes_too then
+ local a = n[a_marks]
+ if not a then
+ -- next
+ elseif first == 0 then
+ first, last = a, a
+ elseif a > last then
+ last = a
+ end
end
local list = n.list
if list then
@@ -528,20 +533,22 @@ local function do_first(name,range,check)
report_marks("action %a, name %a, range %a","resolving first",name,range)
end
local f_value, f_index, f_found = doresolve(name,range,false,0,0,check)
- if trace_marks_get then
- report_marks("action %a, name %a, range %a","resolving last",name,range)
- end
- local l_value, l_index, l_found = doresolve(name,range,true ,0,0,check)
- if f_found and l_found and l_index > f_index then
- local name = parentname(name)
- for i=f_index,l_index,1 do
- local si = stack[i]
- local sn = si[name]
- if sn and sn ~= false and sn ~= true and sn ~= "" and sn ~= f_value then
- if trace_marks_get then
- report_marks("action %a, name %a, range %a, index %a, value %a","resolving",name,range,i,sn)
+ if f_found then
+ if trace_marks_get then
+ report_marks("action %a, name %a, range %a","resolving last",name,range)
+ end
+ local l_value, l_index, l_found = doresolve(name,range,true ,0,0,check)
+ if l_found and l_index > f_index then
+ local name = parentname(name)
+ for i=f_index,l_index,1 do
+ local si = stack[i]
+ local sn = si[name]
+ if sn and sn ~= false and sn ~= true and sn ~= "" and sn ~= f_value then
+ if trace_marks_get then
+ report_marks("action %a, name %a, range %a, index %a, value %a","resolving",name,range,i,sn)
+ end
+ return sn, i, si
end
- return sn, i, si
end
end
end
@@ -553,23 +560,25 @@ end
local function do_last(name,range,check)
if trace_marks_get then
- report_marks("action %a, name %a, range %a","resolving first",name,range)
- end
- local f_value, f_index, f_found = doresolve(name,range,false,0,0,check)
- if trace_marks_get then
report_marks("action %a, name %a, range %a","resolving last",name,range)
end
local l_value, l_index, l_found = doresolve(name,range,true ,0,0,check)
- if f_found and l_found and l_index > f_index then
- local name = parentname(name)
- for i=l_index,f_index,-1 do
- local si = stack[i]
- local sn = si[name]
- if sn and sn ~= false and sn ~= true and sn ~= "" and sn ~= l_value then
- if trace_marks_get then
- report_marks("action %a, name %a, range %a, index %a, value %a","resolving",name,range,i,sn)
+ if l_found then
+ if trace_marks_get then
+ report_marks("action %a, name %a, range %a","resolving first",name,range)
+ end
+ local f_value, f_index, f_found = doresolve(name,range,false,0,0,check)
+ if f_found and l_index > f_index then
+ local name = parentname(name)
+ for i=l_index,f_index,-1 do
+ local si = stack[i]
+ local sn = si[name]
+ if sn and sn ~= false and sn ~= true and sn ~= "" and sn ~= l_value then
+ if trace_marks_get then
+ report_marks("action %a, name %a, range %a, index %a, value %a","resolving",name,range,i,sn)
+ end
+ return sn, i, si
end
- return sn, i, si
end
end
end