summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-06-13 09:56:22 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2018-06-13 09:56:22 +0200
commit204057fdc5023b5f4ff55a69bc6593388ea427e7 (patch)
tree2153d525f1fb854189772d3109be782a0aeb14fd /tex/context/base/mkiv
parent7686a24f79edfef2a9d013882c822c76a12e23dc (diff)
downloadcontext-204057fdc5023b5f4ff55a69bc6593388ea427e7.tar.gz
2018-06-12 21:56:00
Diffstat (limited to 'tex/context/base/mkiv')
-rw-r--r--tex/context/base/mkiv/cldf-ini.lua82
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/core-env.lua50
-rw-r--r--tex/context/base/mkiv/font-ott.lua16
-rw-r--r--tex/context/base/mkiv/luat-cod.lua8
-rw-r--r--tex/context/base/mkiv/luat-fmt.lua3
-rw-r--r--tex/context/base/mkiv/meta-blb.lua24
-rw-r--r--tex/context/base/mkiv/mlib-lua.lua14
-rw-r--r--tex/context/base/mkiv/mlib-pps.lua66
-rw-r--r--tex/context/base/mkiv/mtx-context-listing.tex2
-rw-r--r--tex/context/base/mkiv/mult-fun.lua2
-rw-r--r--tex/context/base/mkiv/spac-ver.mkiv3
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin26045 -> 26069 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin260193 -> 259985 bytes
-rw-r--r--tex/context/base/mkiv/strc-doc.lua44
-rw-r--r--tex/context/base/mkiv/strc-sec.mkiv11
-rw-r--r--tex/context/base/mkiv/toks-ini.lua3
18 files changed, 214 insertions, 118 deletions
diff --git a/tex/context/base/mkiv/cldf-ini.lua b/tex/context/base/mkiv/cldf-ini.lua
index 54048b52a..dabdbb9b0 100644
--- a/tex/context/base/mkiv/cldf-ini.lua
+++ b/tex/context/base/mkiv/cldf-ini.lua
@@ -1454,7 +1454,7 @@ do
local function indexer(parent,k)
local f = function(...)
- local a = { ... }
+ local a = { ... } -- this also freezes ...
return function()
-- return context[k](unpack(a))
return core[k](unpack(a))
@@ -1479,46 +1479,48 @@ do
end
-do
-
- -- context.nested (todo: lines), creates strings
-
- local nested = { }
-
- local function indexer(parent,k) -- not ok when traced
- local f = function(...)
- local t, savedflush, n = { }, flush, 0
- flush = function(c,f,s,...) -- catcodes are ignored
- n = n + 1
- t[n] = s and concat{f,s,...} or f -- optimized for #args == 1
- end
- -- context[k](...)
- core[k](...)
- flush = savedflush
- return concat(t)
- end
- parent[k] = f
- return f
- end
-
- local function caller(parent,...)
- local t, savedflush, n = { }, flush, 0
- flush = function(c,f,s,...) -- catcodes are ignored
- n = n + 1
- t[n] = s and concat{f,s,...} or f -- optimized for #args == 1
- end
- -- context(...)
- defaultcaller(context,...)
- flush = savedflush
- return concat(t)
- end
-
- setmetatableindex(nested,indexer)
- setmetatablecall (nested,caller)
-
- context.nested = nested
+-- do
+--
+-- -- context.nested (todo: lines), creates strings
+--
+-- local nested = { }
+--
+-- local function indexer(parent,k) -- not ok when traced
+-- local f = function(...)
+-- local t, savedflush, n = { }, flush, 0
+-- flush = function(c,f,s,...) -- catcodes are ignored
+-- n = n + 1
+-- t[n] = s and concat{f,s,...} or f -- optimized for #args == 1
+-- end
+-- -- context[k](...)
+-- core[k](...)
+-- flush = savedflush
+-- return concat(t)
+-- end
+-- parent[k] = f
+-- return f
+-- end
+--
+-- local function caller(parent,...)
+-- local t, savedflush, n = { }, flush, 0
+-- flush = function(c,f,s,...) -- catcodes are ignored
+-- n = n + 1
+-- t[n] = s and concat{f,s,...} or f -- optimized for #args == 1
+-- end
+-- -- context(...)
+-- defaultcaller(context,...)
+-- flush = savedflush
+-- return concat(t)
+-- end
+--
+-- setmetatableindex(nested,indexer)
+-- setmetatablecall (nested,caller)
+--
+-- context.nested = nested
+--
+-- end
-end
+context.nested = context.delayed
-- verbatim
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index 17ace314b..3a9acfb13 100644
--- a/tex/context/base/mkiv/cont-new.mkiv
+++ b/tex/context/base/mkiv/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2018.06.11 12:05}
+\newcontextversion{2018.06.12 21:48}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv
index 8842e4fc3..1e90175c8 100644
--- a/tex/context/base/mkiv/context.mkiv
+++ b/tex/context/base/mkiv/context.mkiv
@@ -42,7 +42,7 @@
%D has to match \type {YYYY.MM.DD HH:MM} format.
\edef\contextformat {\jobname}
-\edef\contextversion{2018.06.11 12:05}
+\edef\contextversion{2018.06.12 21:48}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/core-env.lua b/tex/context/base/mkiv/core-env.lua
index 23f7ca178..ea7bbcb8e 100644
--- a/tex/context/base/mkiv/core-env.lua
+++ b/tex/context/base/mkiv/core-env.lua
@@ -40,14 +40,27 @@ local systemmodes = { }
-- we could use the built-in tex.is[count|dimen|skip|toks] here but caching
-- at the lua end is not that bad (and we need more anyway)
--- undefined: mode == 0 or cmdname = "undefined_cs"
-
local cache = tokens.cache
-- we can have a modes cache too
-local iftrue = cache["iftrue"].mode
-local undefined = cache["*undefined*crap*"].mode -- is this ok?
+local iftrue = cache["iftrue"].mode
+
+local dimencode = cache["scratchdimen"] .command
+local countcode = cache["scratchcounter"] .command
+local tokencode = cache["scratchtoken"] .command
+local skipcode = cache["scratchskip"] .command
+local muskipcode = cache["scratchmuskip"] .command
+----- attributecode = cache["scratchattribute"].command
+
+local types = {
+ [dimencode] = "dimen",
+ [countcode] = "count",
+ [tokencode] = "token",
+ [skipcode] = "skip",
+ [muskipcode] = "muskip",
+ -- [attributecode] = "attribute",
+}
setmetatableindex(texmodes, function(t,k)
local m = modes[k]
@@ -55,16 +68,17 @@ setmetatableindex(texmodes, function(t,k)
return m()
elseif k then
local n = "mode>" .. k
- if cache[n].mode == 0 then
- return false
- else
+ if is_defined then
rawset(modes,k, function() return texgetcount(n) == 1 end)
return texgetcount(n) == 1 -- 2 is prevented
+ else
+ return false
end
else
return false
end
end)
+
setmetatablenewindex(texmodes, function(t,k)
report_mode("you cannot set the %s named %a this way","mode",k)
end)
@@ -75,11 +89,11 @@ setmetatableindex(texsystemmodes, function(t,k)
return m()
else
local n = "mode>*" .. k
- if cache[n].mode == 0 then
- return false
- else
+ if is_defined(n) then
rawset(systemmodes,k,function() return texgetcount(n) == 1 end)
return texgetcount(n) == 1 -- 2 is prevented
+ else
+ return false
end
end
end)
@@ -118,22 +132,6 @@ setmetatablenewindex(texisdefined, function(t,k)
-- just ignore
end)
-local dimencode = cache["scratchdimen"] .command
-local countcode = cache["scratchcounter"] .command
-local tokencode = cache["scratchtoken"] .command
-local skipcode = cache["scratchskip"] .command
-local muskipcode = cache["scratchmuskip"] .command
----- attributecode = cache["scratchattribute"].command
-
-local types = {
- [dimencode] = "dimen",
- [countcode] = "count",
- [tokencode] = "token",
- [skipcode] = "skip",
- [muskipcode] = "muskip",
- -- [attributecode] = "attribute",
-}
-
function tex.isdimen(name)
local hit = cache[name]
return hit.command == dimencode and hit.index or true
diff --git a/tex/context/base/mkiv/font-ott.lua b/tex/context/base/mkiv/font-ott.lua
index c9e2836d8..88da136ac 100644
--- a/tex/context/base/mkiv/font-ott.lua
+++ b/tex/context/base/mkiv/font-ott.lua
@@ -988,9 +988,13 @@ setmetatableindex(languages, function(t,k)
return "dflt"
end)
-setmetatablenewindex(languages, "ignore")
-setmetatablenewindex(baselines, "ignore")
-setmetatablenewindex(baselines, "ignore")
+if setmetatablenewindex then
+
+ setmetatablenewindex(languages, "ignore")
+ setmetatablenewindex(scripts, "ignore")
+ setmetatablenewindex(baselines, "ignore")
+
+end
local function resolve(t,k)
if k then
@@ -1030,7 +1034,11 @@ local function assign(t,k,v)
end
end
-setmetatablenewindex(features, assign)
+if setmetatablenewindex then
+
+ setmetatablenewindex(features, assign)
+
+end
local checkers = {
rand = function(v)
diff --git a/tex/context/base/mkiv/luat-cod.lua b/tex/context/base/mkiv/luat-cod.lua
index 63a51b4fc..f74c53e82 100644
--- a/tex/context/base/mkiv/luat-cod.lua
+++ b/tex/context/base/mkiv/luat-cod.lua
@@ -49,6 +49,8 @@ end
-- no file.* and utilities.parsers.* functions yet
+local strip = false if arg then for i=-1,#arg do if arg[i] == "--c:strip" then strip = true break end end end
+
function lua.registercode(filename,options)
local barename = gsub(filename,"%.[%a%d]+$","")
if barename == filename then filename = filename .. ".lua" end
@@ -66,7 +68,11 @@ function lua.registercode(filename,options)
if environment.initex then
local n = lua.lastbytecode + 1
bytedata[n] = { name = barename, options = opts }
- setbytecode(n,code)
+ if strip or opts.strip then
+ setbytecode(n,code,true)
+ else
+ setbytecode(n,code)
+ end
lua.lastbytecode = n
end
elseif environment.initex then
diff --git a/tex/context/base/mkiv/luat-fmt.lua b/tex/context/base/mkiv/luat-fmt.lua
index 3e08a86f0..2abc47094 100644
--- a/tex/context/base/mkiv/luat-fmt.lua
+++ b/tex/context/base/mkiv/luat-fmt.lua
@@ -48,6 +48,9 @@ local function secondaryflags()
if arguments.ansi then
flags[#flags+1] = "--c:ansi"
end
+ if arguments.strip then
+ flags[#flags+1] = "--c:strip"
+ end
return concat(flags," ")
end
diff --git a/tex/context/base/mkiv/meta-blb.lua b/tex/context/base/mkiv/meta-blb.lua
index 957af16ca..d3418199c 100644
--- a/tex/context/base/mkiv/meta-blb.lua
+++ b/tex/context/base/mkiv/meta-blb.lua
@@ -196,7 +196,12 @@ local function process(object,prescript,before,after)
-- end
end
-metapost.installplugin(reset,analyze,process)
+metapost.installplugin {
+ name = "texblob",
+ reset = reset,
+ analyze = analyze,
+ process = process,
+}
-- Here follows an example of usage of the above: a more modern
-- version of followokens (in meta-imp-txt.mkiv).
@@ -279,7 +284,7 @@ interfaces.implement {
actions = initialize,
}
-local tb_reset, tb_analyze, tb_process do
+local ft_reset, ft_analyze, ft_process do
if metapost.use_one_pass then
@@ -300,7 +305,7 @@ local tb_reset, tb_analyze, tb_process do
end
}
- tb_process = function(object,prescript,before,after)
+ ft_process = function(object,prescript,before,after)
object.path = false
object.color = false
object.grouped = true
@@ -310,11 +315,11 @@ local tb_reset, tb_analyze, tb_process do
else
- tb_reset = function()
+ ft_reset = function()
-- nothing
end
- tb_analyze = function(object,prescript)
+ ft_analyze = function(object,prescript)
if prescript.ft_stage == "trial" then
local ft_category = tonumber(prescript.ft_category)
if ft_category then
@@ -325,7 +330,7 @@ local tb_reset, tb_analyze, tb_process do
end
end
- tb_process = function(object,prescript,before,after)
+ ft_process = function(object,prescript,before,after)
if prescript.ft_stage == "final" then
object.path = false
object.color = false
@@ -339,4 +344,9 @@ local tb_reset, tb_analyze, tb_process do
end
-metapost.installplugin(tb_reset,tb_analyze,tb_process)
+metapost.installplugin {
+ name = "followtext",
+ reset = ft_reset,
+ analyze = ft_analyze,
+ process = ft_process,
+}
diff --git a/tex/context/base/mkiv/mlib-lua.lua b/tex/context/base/mkiv/mlib-lua.lua
index 675be15bc..543d04697 100644
--- a/tex/context/base/mkiv/mlib-lua.lua
+++ b/tex/context/base/mkiv/mlib-lua.lua
@@ -776,3 +776,17 @@ do
end
end
+
+do
+
+ -- a bit overkill: just a find(str,"mf_object=") can be enough
+
+ local p1 = P("mf_object=")
+ local p2 = lpeg.patterns.eol * p1
+ local pattern = (1-p2)^0 * p2 + p1
+
+ function mp.isobject(str)
+ mp.boolean(pattern and str ~= "" and lpegmatch(p,str))
+ end
+
+end
diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua
index 3d361f835..da1e9c4f7 100644
--- a/tex/context/base/mkiv/mlib-pps.lua
+++ b/tex/context/base/mkiv/mlib-pps.lua
@@ -842,10 +842,6 @@ local sequencers = utilities.sequencers
local appendgroup = sequencers.appendgroup
local appendaction = sequencers.appendaction
-local resetter = nil
-local analyzer = nil
-local processor = nil
-
local resetteractions = sequencers.new { arguments = "t" }
local analyzeractions = sequencers.new { arguments = "object,prescript" }
local processoractions = sequencers.new { arguments = "object,prescript,before,after" }
@@ -914,7 +910,7 @@ end
function metapost.resetplugins(t) -- intialize plugins, before figure
if top.plugmode then
outercolormodel = colors.currentmodel() -- currently overloads the one set at the tex end
- resetter(t)
+ resetteractions.runner(t)
end
end
@@ -922,7 +918,7 @@ function metapost.analyzeplugins(object) -- each object (first pass)
if top.plugmode then
local prescript = object.prescript -- specifications
if prescript and #prescript > 0 then
- analyzer(object,splitprescript(prescript) or {})
+ analyzeractions.runner(object,splitprescript(prescript) or {})
return top.multipass
end
end
@@ -935,7 +931,7 @@ function metapost.processplugins(object) -- each object (second pass)
if prescript and #prescript > 0 then
local before = { }
local after = { }
- processor(object,splitprescript(prescript) or {},before,after)
+ processoractions.runner(object,splitprescript(prescript) or {},before,after)
return #before > 0 and before, #after > 0 and after
else
local c = object.color
@@ -1850,31 +1846,21 @@ local ot_reset, ot_analyze, ot_process do
end
--- definitions
-
-appendaction(resetteractions, "system",ot_reset)
-appendaction(resetteractions, "system",cl_reset)
-appendaction(resetteractions, "system",tx_reset)
-
-appendaction(processoractions,"system",ot_process)
-appendaction(processoractions,"system",gr_process)
+-- mf_object=<string>
-appendaction(analyzeractions, "system",ot_analyze)
-appendaction(analyzeractions, "system",tx_analyze)
-appendaction(analyzeractions, "system",gt_analyze)
+local p1 = P("mf_object=")
+local p2 = lpeg.patterns.eol * p1
+local pattern = (1-p2)^0 * p2 + p1
-appendaction(processoractions,"system",sh_process)
--- (processoractions,"system",gt_process)
-appendaction(processoractions,"system",bm_process)
-appendaction(processoractions,"system",tx_process)
-appendaction(processoractions,"system",bx_process)
-appendaction(processoractions,"system",ps_process)
-appendaction(processoractions,"system",fg_process)
-appendaction(processoractions,"system",tr_process) -- last, as color can be reset
-
-appendaction(processoractions,"system",la_process)
+function metapost.isobject(str)
+ return pattern and str ~= "" and lpegmatch(p,str) and true or false
+end
-function metapost.installplugin(reset,analyze,process)
+local function installplugin(specification)
+ local reset = specification.reset
+ local analyze = specification.analyze
+ local process = specification.process
+ local object = specification.object
if reset then
appendaction(resetteractions,"system",reset)
end
@@ -1884,13 +1870,21 @@ function metapost.installplugin(reset,analyze,process)
if process then
appendaction(processoractions,"system",process)
end
- resetter = resetteractions .runner
- analyzer = analyzeractions .runner
- processor = processoractions.runner
end
--- we're nice and set them already
+metapost.installplugin = installplugin
+
+-- definitions
-resetter = resetteractions .runner
-analyzer = analyzeractions .runner
-processor = processoractions.runner
+installplugin { name = "outline", reset = ot_reset, analyze = ot_analyze, process = ot_process }
+installplugin { name = "color", reset = cl_reset, analyze = cl_analyze, process = cl_process }
+installplugin { name = "text", reset = tx_reset, analyze = tx_analyze, process = tx_process }
+installplugin { name = "group", reset = gr_reset, analyze = gr_analyze, process = gr_process }
+installplugin { name = "graphictext", reset = gt_reset, analyze = gt_analyze, process = gt_process }
+installplugin { name = "shade", reset = sh_reset, analyze = sh_analyze, process = sh_process }
+installplugin { name = "bitmap", reset = bm_reset, analyze = bm_analyze, process = bm_process }
+installplugin { name = "box", reset = bx_reset, analyze = bx_analyze, process = bx_process }
+installplugin { name = "position", reset = ps_reset, analyze = ps_analyze, process = ps_process }
+installplugin { name = "figure", reset = fg_reset, analyze = fg_analyze, process = fg_process }
+installplugin { name = "layer", reset = la_reset, analyze = la_analyze, process = la_process }
+installplugin { name = "transparency", reset = tr_reset, analyze = tr_analyze, process = tr_process }
diff --git a/tex/context/base/mkiv/mtx-context-listing.tex b/tex/context/base/mkiv/mtx-context-listing.tex
index f7c3d2868..29c4999ae 100644
--- a/tex/context/base/mkiv/mtx-context-listing.tex
+++ b/tex/context/base/mkiv/mtx-context-listing.tex
@@ -44,7 +44,7 @@
}
\setupbodyfont
- [dejavu,11pt,tt,\getdocumentargument{bodyfont}] % dejavu is more complete
+ [dejavu,9pt,tt,\getdocumentargument{bodyfont}] % dejavu is more complete
\setuptyping
[lines=yes]
diff --git a/tex/context/base/mkiv/mult-fun.lua b/tex/context/base/mkiv/mult-fun.lua
index caac199de..c6b3a9377 100644
--- a/tex/context/base/mkiv/mult-fun.lua
+++ b/tex/context/base/mkiv/mult-fun.lua
@@ -145,5 +145,7 @@ return {
"sortlist", "copylist", "shapedlist", "listtocurves", "listtolines", "listsize", "listlast", "uniquelist",
--
"circularpath", "squarepath", "linearpath",
+ --
+ "theoffset",
},
}
diff --git a/tex/context/base/mkiv/spac-ver.mkiv b/tex/context/base/mkiv/spac-ver.mkiv
index 4c78dfd69..cb08fa14a 100644
--- a/tex/context/base/mkiv/spac-ver.mkiv
+++ b/tex/context/base/mkiv/spac-ver.mkiv
@@ -2420,13 +2420,14 @@
\scratchwidth\dimexpr\wd\nextbox+\scratchdistance\relax
\ifx\m_spac_hanging_location\v!right
\hangindent\ifconditional\displaylefttoright-\fi\scratchwidth
- \rlap{\hskip\dimexpr\hsize-\wd\nextbox\relax\box\nextbox}%
+ \rlap{\hskip\dimexpr\hsize-\leftskip-\wd\nextbox\relax\box\nextbox}% \leftskip is new
\else
\hangindent\ifconditional\displaylefttoright\else-\fi\scratchwidth
\llap{\box\nextbox\hskip\scratchdistance}%
\fi
\ignorespaces}
+
%D \macros
%D {startfixed}
%D
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 8697305df..4a95efec4 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index 5e4f1b448..bd1efee16 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/strc-doc.lua b/tex/context/base/mkiv/strc-doc.lua
index 2de26ac64..80e41451e 100644
--- a/tex/context/base/mkiv/strc-doc.lua
+++ b/tex/context/base/mkiv/strc-doc.lua
@@ -18,6 +18,7 @@ if not modules then modules = { } end modules ['strc-doc'] = {
local next, type, tonumber, select = next, type, tonumber, select
local find, match = string.find, string.match
local concat, fastcopy, insert, remove = table.concat, table.fastcopy, table.insert, table.remove
+local sortedhash, sortedkeys = table.sortedhash, table.sortedkeys
local max, min = math.max, math.min
local allocate, mark, accesstable = utilities.storage.allocate, utilities.storage.mark, utilities.tables.accesstable
local setmetatableindex = table.setmetatableindex
@@ -42,6 +43,7 @@ local trace_sectioning = false trackers.register("structures.sectioning", fu
local trace_detail = false trackers.register("structures.detail", function(v) trace_detail = v end)
local report_structure = logs.reporter("structure","sectioning")
+local report_used = logs.reporter("structure")
local context = context
local commands = commands
@@ -972,6 +974,47 @@ function sections.getnumber(depth,what) -- redefined here
context(askednumber)
end
+-- maybe handy
+
+function sections.showstructure()
+
+ local tobesaved = structures.lists.tobesaved
+
+ if not tobesaved then
+ return
+ end
+
+ local levels = setmetatableindex("table")
+ local names = setmetatableindex("table")
+
+ report_used()
+ report_used("sections")
+ for i=1,#tobesaved do
+ local si = tobesaved[i]
+ local md = si.metadata
+ if md and md.kind == "section" then
+ local level = md.level
+ local name = md.name
+ local numbers = si.numberdata.numbers
+ local title = si.titledata.title
+ report_used(" %i : %-10s %-20s %s",level,concat(numbers,"."),name,title)
+ levels[level][name] = true
+ names[name][level] = true
+ end
+ end
+ report_used()
+ report_used("levels")
+ for level, list in sortedhash(levels) do
+ report_used(" %s : % t",level,sortedkeys(list))
+ end
+ report_used()
+ report_used("names")
+ for name, list in sortedhash(names) do
+ report_used(" %-10s : % t",name,sortedkeys(list))
+ end
+ report_used()
+end
+
-- experimental
local levels = { }
@@ -1042,6 +1085,7 @@ implement { name = "getsomefullstructurenumber", actions = sections.fullnumber,
implement { name = "getspecificstructuretitle", actions = sections.structuredata, arguments = { "string", "'titledata.title'",false,"string" } }
implement { name = "reportstructure", actions = sections.reportstructure }
+implement { name = "showstructure", actions = sections.showstructure }
implement {
name = "registersection",
diff --git a/tex/context/base/mkiv/strc-sec.mkiv b/tex/context/base/mkiv/strc-sec.mkiv
index 4cc2c7bd6..82c6d7ea7 100644
--- a/tex/context/base/mkiv/strc-sec.mkiv
+++ b/tex/context/base/mkiv/strc-sec.mkiv
@@ -816,6 +816,17 @@
\let\currentheadlevel \!!zerocount
\let\currentheadcounter \!!zerocount
+\let\strc_show_used\relax
+
+\installtextracker
+ {structures.showused}
+ {\let\strc_show_used\clf_showstructure}
+ {\let\strc_show_used\relax}
+
+\appendtoks
+ \strc_show_used
+\to \everystoptext
+
\unexpanded\def\placeheadtext {\dosingleempty\strc_sectioning_place_head_text } % use with care
\unexpanded\def\placeheadnumber{\dosingleempty\strc_sectioning_place_head_number} % use with care
diff --git a/tex/context/base/mkiv/toks-ini.lua b/tex/context/base/mkiv/toks-ini.lua
index dfdf854d0..43e2d80a3 100644
--- a/tex/context/base/mkiv/toks-ini.lua
+++ b/tex/context/base/mkiv/toks-ini.lua
@@ -315,6 +315,9 @@ if setinspector then
end
tokens.cache = table.setmetatableindex(function(t,k)
+ if not is_defined(k) then
+ set_macro(k,"","global")
+ end
local v = create_token(k)
t[k] = v
return v