diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-ini.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/strc-ini.lua | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-ini.lua b/Master/texmf-dist/tex/context/base/strc-ini.lua index 78efcad815a..fd7c10f7952 100644 --- a/Master/texmf-dist/tex/context/base/strc-ini.lua +++ b/Master/texmf-dist/tex/context/base/strc-ini.lua @@ -20,17 +20,24 @@ but it does not make sense to store all processdata. ]]-- -local format, concat = string.format, table.concat +local formatters = string.formatters local lpegmatch = lpeg.match local count = tex.count -local type, next, tonumber = type, next, tonumber +local type, next, tonumber, select = type, next, tonumber, select local settings_to_array, settings_to_hash = utilities.parsers.settings_to_array, utilities.parsers.settings_to_hash local allocate = utilities.storage.allocate -local ctxcatcodes = tex.ctxcatcodes -local xmlcatcodes = tex.xmlcatcodes -local notcatcodes = tex.notcatcodes -local txtcatcodes = tex.txtcatcodes +local catcodenumbers = catcodes.numbers -- better use the context(...) way to switch + +local ctxcatcodes = catcodenumbers.ctxcatcodes +local xmlcatcodes = catcodenumbers.xmlcatcodes +local notcatcodes = catcodenumbers.notcatcodes +local txtcatcodes = catcodenumbers.txtcatcodes + +local context, commands = context, commands + +local pushcatcodes = context.pushcatcodes +local popcatcodes = context.popcatcodes local trace_processors = false local report_processors = logs.reporter("processors","structure") @@ -162,9 +169,9 @@ end helpers.simplify = simplify function helpers.merged(...) - local h, t = { ... }, { } - for k=1, #h do - local v = h[k] + local t = { } + for k=1, select("#",...) do + local v = select(k,...) if v and v ~= "" and not t[k] then t[k] = v end @@ -183,7 +190,7 @@ local tags = { -- (optionally) as a setups to be applied but keep in mind that document setups -- also get applied (when they use #1's). -- --- local command = format("\\xmlprocessbuffer{%s}{%s}{}",metadata.xmlroot or "main",tag) +-- local command = formatters["\\xmlprocessbuffer{%s}{%s}{}"](metadata.xmlroot or "main",tag) local experiment = true @@ -194,39 +201,47 @@ function helpers.title(title,metadata) -- coding is xml is rather old and not th if metadata.coding == "xml" then -- title can contain raw xml local tag = tags[metadata.kind] or tags.generic - local xmldata = format("<?xml version='1.0'?><%s>%s</%s>",tag,title,tag) -if not experiment then - buffers.assign(tag,xmldata) -end + local xmldata = formatters["<?xml version='1.0'?><%s>%s</%s>"](tag,title,tag) + if not experiment then + buffers.assign(tag,xmldata) + end if trace_processors then report_processors("putting xml data in buffer: %s",xmldata) - report_processors("processing buffer with setup '%s' and tag '%s'",xmlsetup or "",tag) + report_processors("processing buffer with setup %a and tag %a",xmlsetup,tag) end -if experiment then - -- the question is: will this be forgotten ... better store in a via file - local xmltable = lxml.convert("temp",xmldata or "") - lxml.store("temp",xmltable) - context.xmlsetup("temp",xmlsetup or "") -else + if experiment then + -- the question is: will this be forgotten ... better store in a via file + local xmltable = lxml.convert("temp",xmldata or "") + lxml.store("temp",xmltable) + context.xmlsetup("temp",xmlsetup or "") + else context.xmlprocessbuffer("dummy",tag,xmlsetup or "") -end + end elseif xmlsetup then -- title is reference to node (so \xmlraw should have been used) if trace_processors then - report_processors("feeding xmlsetup '%s' using node '%s'",xmlsetup,title) + report_processors("feeding xmlsetup %a using node %a",xmlsetup,title) end context.xmlsetup(title,metadata.xmlsetup) else local catcodes = metadata.catcodes if catcodes == notcatcodes or catcodes == xmlcatcodes then if trace_processors then - report_processors("cct: %s (overloads %s), txt: %s",ctxcatcodes,catcodes,title) + report_processors("catcodetable %a, overloads %a, text %a",ctxcatcodes,catcodes,title) end context(title) -- nasty else if trace_processors then - report_processors("cct: %s, txt: %s",catcodes,title) + report_processors("catcodetable %a, text %a",catcodes,title) end - context.sprint(catcodes,title) -- was: texsprint(catcodes,title) + -- + -- context.sprint(catcodes,title) + -- + -- doesn't work when a newline is in there \section{Test\ A} so we do + -- it this way: + -- + pushcatcodes(catcodes) + context(title) + popcatcodes() end end else |