diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/x-set-11.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/x-set-11.mkiv | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/x-set-11.mkiv b/Master/texmf-dist/tex/context/base/x-set-11.mkiv new file mode 100644 index 00000000000..7e208a085e2 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/x-set-11.mkiv @@ -0,0 +1,98 @@ +% engine=luatex + +\startluacode + do + document = document or { } + + document.setups = { + loaded = { }, + root = nil, + used = { }, + } + + function document.setups.load(filename) + filename = input.find_file(texmf.instance,filename) or "" + if filename ~= "" and not document.setups.loaded[filename] then + local loaded = xml.load(filename) + if loaded then + if document.setups.root then + xml.inject(document.setups.root,"/",loaded) + else + document.setups.root = loaded + end + document.setups.loaded[filename] = true + end + end + end + function document.setups.name(ek) + local at = ek.at + local name = at.name + if at.type == 'environment' then + name = "start" .. name + end + if at.variant then + name = name .. ":" .. at.variant + end + if at.generated == "yes" then + name = name .. "*" + end + return name:lower() + end + function document.setups.show(name) + if document.setups.root then + local name = name:gsub("[<>]","") + local setup = xml.first(document.setups.root,"cd:command[@name='" .. name .. "']") + document.setups.used[#document.setups.used+1] = setup + xml.sprint(setup) + end + end + function document.setups.showused() + if document.setups.root and next(document.setups.used) then + for k,v in ipairs(table.sortedkeys(document.setups.used)) do + xml.sprint(document.setups.used[v]) + end + end + end + function document.setups.showall() + if document.setups.root then + local list = { } + xml.each_element(document.setups.root,"cd:command", function(r,d,t) + local ek = d[t] + list[document.setups.name(ek)] = ek + end ) + for k,v in ipairs(table.sortedkeys(list)) do + xml.sprint(list[v]) + end + end + end + function document.setups.resolve(name) + if document.setups.root then + local e = xml.filter(document.setups.root,string.format("cd:define[@name='%s']/text()",name)) + if e then + xml.sprint(e) + end + end + end + end +\stopluacode + +\def\mkloadsetups #1{\ctxlua{document.setups.load("#1")}} +\def\mkshowsetup #1{\ctxlua{document.setups.show("#1")}} +\def\mlshowusedsetups {\bgroup\enableXML\ctxlua{document.setups.showused()}\egroup} +\def\mkshowallsetups {\bgroup\enableXML\ctxlua{document.setups.showall ()}\egroup} + +\def\mkshowsetup #1{\bgroup\enableXML\ctxlua{document.setups.show("#1")}\egroup} + +\defineXMLenvironmentsave [cd:define] [name=] + {} + +\defineXMLsingular [cd:resolve] [name=] + {\enableXML\ignorespaces\ctxlua{document.setups.resolve("\XMLop{name}")}} + +\endinput + +% \starttext +% \loadsetups[cont-en.xml] +% \setup[goto] +% \placeeverysetup +% \stoptext |