diff options
Diffstat (limited to 'tex/context/base/strc-mar.lua')
-rw-r--r-- | tex/context/base/strc-mar.lua | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/tex/context/base/strc-mar.lua b/tex/context/base/strc-mar.lua index 02d676fb9..7b3ac11e1 100644 --- a/tex/context/base/strc-mar.lua +++ b/tex/context/base/strc-mar.lua @@ -12,9 +12,7 @@ if not modules then modules = { } end modules ['strc-mar'] = { local insert, concat = table.insert, table.concat local tostring, next, rawget = tostring, next, rawget local lpegmatch = lpeg.match - -local context = context -local commands = commands +local match = string.match local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex @@ -24,10 +22,9 @@ local glyph_code = nodecodes.glyph local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist -local traversenodes = nodes.traverse - +local traversenodes = node.traverse local texsetattribute = tex.setattribute -local texgetbox = tex.getbox +local texbox = tex.box local a_marks = attributes.private("structure","marks") @@ -124,7 +121,7 @@ local function sweep(head,first,last) end local list = n.list if list then - first, last = sweep(list,first,last) + first, last = sweep(list, first, last) end end end @@ -138,7 +135,7 @@ setmetatableindex(classes, function(t,k) local s = settings_to_array(k) t[k] = s local lasts = { } function marks.synchronize(class,n,option) - local box = texgetbox(n) + local box = texbox[n] if box then local first, last = sweep(box.list,0,0) if option == v_keep and first == 0 and last == 0 then @@ -154,16 +151,11 @@ function marks.synchronize(class,n,option) for i=1,#classlist do local class = classlist[i] local range = ranges[class] - if range then - range.first = first - range.last = last - else - range = { - first = first, - last = last, - } + if not range then + range = { } ranges[class] = range end + range.first, range.last = first, last if trace_marks_get or trace_marks_set then report_marks("action %a, class %a, first %a, last %a","synchronize",class,range.first,range.last) end @@ -667,10 +659,8 @@ function marks.fetchallmarks(name,range) fetchallmarks(name,range ) -- here we have a few helpers .. will become commands.* -local pattern = lpeg.afterprefix("li::") - function marks.title(tag,n) - local listindex = lpegmatch(pattern,n) + local listindex = match(n,"^li::(.-)$") if listindex then commands.savedlisttitle(tag,listindex,"marking") else @@ -679,7 +669,7 @@ function marks.title(tag,n) end function marks.number(tag,n) -- no spec - local listindex = lpegmatch(pattern,n) + local listindex = match(n,"^li::(.-)$") if listindex then commands.savedlistnumber(tag,listindex) else |