summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/strc-blk.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-blk.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/strc-blk.lua72
1 files changed, 36 insertions, 36 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-blk.lua b/Master/texmf-dist/tex/context/base/strc-blk.lua
index 2589190eb5c..cbdc8c6ea36 100644
--- a/Master/texmf-dist/tex/context/base/strc-blk.lua
+++ b/Master/texmf-dist/tex/context/base/strc-blk.lua
@@ -1,4 +1,4 @@
-if not modules then modules = { } end modules ['strc--blk'] = {
+if not modules then modules = { } end modules ['strc-blk'] = {
version = 1.001,
comment = "companion to strc-blk.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
@@ -8,47 +8,49 @@ if not modules then modules = { } end modules ['strc--blk'] = {
-- this one runs on top of buffers and structure
-local texprint, format, gmatch, find = tex.print, string.format, string.gmatch, string.find
+local type = type
+local gmatch, find = string.gmatch, string.find
local lpegmatch = lpeg.match
+local settings_to_set, settings_to_array = utilities.parsers.settings_to_set, utilities.parsers.settings_to_array
+local allocate, mark = utilities.storage.allocate, utilities.storage.mark
-local ctxcatcodes = tex.ctxcatcodes
+local structures, context = structures, context
-structure = structure or { }
-structure.blocks = structure.blocks or { }
+structures.blocks = structures.blocks or { }
-local blocks = structure.blocks
+local blocks = structures.blocks
+local sections = structures.sections
+local lists = structures.lists
-blocks.collected = blocks.collected or { }
-blocks.tobesaved = blocks.tobesaved or { }
-blocks.states = blocks.states or { }
+local collected = allocate()
+local tobesaved = allocate()
+local states = allocate()
-local tobesaved, collected, states = blocks.tobesaved, blocks.collected, blocks.states
+blocks.collected = collected
+blocks.tobesaved = tobesaved
+blocks.states = states
local function initializer()
- collected, tobesaved = blocks.collected, blocks.tobesaved
+ collected = blocks.collected
+ tobesaved = blocks.tobesaved
end
-job.register('structure.blocks.collected', structure.blocks.tobesaved, initializer)
+job.register('structures.blocks.collected', tobesaved, initializer)
-local printer = (lpeg.patterns.textline/texprint)^0 -- can be shared
+local printer = (lpeg.patterns.textline/tex.print)^0 -- can be shared
+local listitem = utilities.parsers.listitem
function blocks.print(name,data,hide)
if hide then
- texprint(ctxcatcodes,format("\\dostarthiddenblock{%s}",name))
+ context.dostarthiddenblock(name)
else
- texprint(ctxcatcodes,format("\\dostartnormalblock{%s}",name))
- end
- if type(data) == "table" then
- for i=1,#data do
- texprint(data[i])
- end
- else
- lpegmatch(printer,data)
+ context.dostartnormalblock(name)
end
+ context.viafile(data)
if hide then
- texprint(ctxcatcodes,"\\dostophiddenblock")
+ context.dostophiddenblock()
else
- texprint(ctxcatcodes,"\\dostopnormalblock")
+ context.dostopnormalblock()
end
end
@@ -58,8 +60,8 @@ end
function blocks.setstate(state,name,tag)
local all = tag == ""
- local tags = not all and aux.settings_to_array(tag)
- for n in gmatch(name,"%s*([^,]+)") do
+ local tags = not all and settings_to_array(tag)
+ for n in listitem(name) do
local sn = states[n]
if not sn then
-- error
@@ -73,17 +75,15 @@ function blocks.setstate(state,name,tag)
end
end
---~ filter_collected(names, criterium, number, collected)
-
function blocks.select(state,name,tag,criterium)
criterium = criterium or "text"
if find(tag,"=") then tag = "" end
- local names = aux.settings_to_set(name)
+ local names = settings_to_set(name)
local all = tag == ""
- local tags = not all and aux.settings_to_set(tag)
+ local tags = not all and settings_to_set(tag)
local hide = state == "process"
- local n = structure.sections.number_at_depth(criterium)
- local result = structure.lists.filter_collected("all", criterium, n, collected)
+ local n = sections.numberatdepth(criterium)
+ local result = lists.filtercollected("all", criterium, n, collected, { })
for i=1,#result do
local ri = result[i]
local metadata = ri.metadata
@@ -104,8 +104,8 @@ function blocks.select(state,name,tag,criterium)
end
function blocks.save(name,tag,buffer) -- wrong, not yet adapted
- local data = buffers.data[buffer]
- local tags = aux.settings_to_set(tag)
+ local data = buffers.getcontent(buffer)
+ local tags = settings_to_set(tag)
local plus, minus = false, false
if tags['+'] then plus = true tags['+'] = nil end
if tags['-'] then minus = true tags['-'] = nil end
@@ -117,7 +117,7 @@ function blocks.save(name,tag,buffer) -- wrong, not yet adapted
minus = minus,
},
references = {
- section = structure.sections.currentid(),
+ section = sections.currentid(),
},
data = data or "error",
}
@@ -142,5 +142,5 @@ function blocks.save(name,tag,buffer) -- wrong, not yet adapted
end
end
end
- buffers.data[buffer] = nil
+ buffers.erase(buffer)
end