summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/strc-ini.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-ini.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/strc-ini.lua42
1 files changed, 31 insertions, 11 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-ini.lua b/Master/texmf-dist/tex/context/base/strc-ini.lua
index 06f5ff82f82..61c26a20eed 100644
--- a/Master/texmf-dist/tex/context/base/strc-ini.lua
+++ b/Master/texmf-dist/tex/context/base/strc-ini.lua
@@ -1,13 +1,12 @@
if not modules then modules = { } end modules ['strc-ini'] = {
version = 1.001,
- comment = "companion to strc-ini.tex",
+ comment = "companion to strc-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
}
--[[
-
The restructuring is the (intermediate) result of quite some experiments. I started
with the basic structure, followed by lists, numbers, enumerations, itemgroups
and floats. All these have something in common, like pagenumbers and section
@@ -24,8 +23,11 @@ but it does not make sense to store all processdata.
local format, concat, match = string.format, table.concat, string.match
local count, texwrite, texprint, texsprint = tex.count, tex.write, tex.print, tex.sprint
local type, next, tonumber, tostring = type, next, tonumber, tostring
+local lpegmatch = lpeg.match
+
+local ctxcatcodes, xmlcatcodes, notcatcodes = tex.ctxcatcodes, tex.xmlcatcodes, tex.notcatcodes -- tricky as we're in notcatcodes
-local ctxcatcodes = tex.ctxcatcodes
+local trace_processors = false trackers.register("structure.processors", function(v) trace_processors = v end)
-- move this
@@ -150,16 +152,29 @@ function helpers.merged(...)
return t
end
-local tag = "ctx:tocentry"
+local tags = {
+ generic = "ctx:genericentry",
+ section = "ctx:sectionentry",
+ entry = "ctx:registerentry",
+}
-function helpers.title(title,metadata)
+function helpers.title(title,metadata) -- brrr
if title and title ~= "" then
if metadata then
if metadata.coding == "xml" then
+ tag = tags[metadata.kind] or tags.generic
buffers.set(tag,format("<?xml version='1.0'?><%s>%s</%s>",tag,title,tag))
texsprint(ctxcatcodes,format("\\xmlprocessbuffer{%s}{%s}{}",metadata.xmlroot or "main",tag))
+ elseif metadata.xmlsetup then
+ texsprint(ctxcatcodes,format("\\xmlsetup{%s}{%s}",title,metadata.xmlsetup)) -- nasty
else
- texsprint(metadata.catcodes,title)
+ local catcodes = metadata.catcodes
+--~ print(tex.ctxcatcodes,tex.xmlcatcodes,catcodes,title)
+ if catcodes == notcatcodes or catcodes == xmlcatcodes then
+ texsprint(ctxcatcodes,title) -- nasty
+ else
+ texsprint(catcodes,title)
+ end
end
else
texsprint(title) -- no catcode switch
@@ -184,7 +199,7 @@ end
local splitter = lpeg.splitat("->",true)
function processors.split(str)
- local p, s = splitter:match(str)
+ local p, s = lpegmatch(splitter,str)
if registered[p] then
return p, s
else
@@ -193,16 +208,21 @@ function processors.split(str)
end
function processors.sprint(catcodes,str,fnc,...)
- local p, s = splitter:match(str)
+ local p, s = lpegmatch(splitter,str)
+ local code
if registered[p] then
- texsprint(catcodes,format("\\applyprocessor{%s}{%s}",p,(fnc and fnc(s,...)) or s))
+ code = format("\\applyprocessor{%s}{%s}",p,(fnc and fnc(s,...)) or s)
else
- texsprint(catcodes,(fnc and fnc(str,...)) or str)
+ code = (fnc and fnc(str,...)) or str
+ end
+ if trace_processors then
+ logs.report("processors","cct: %s, seq: %s",catcodes,code)
end
+ texsprint(catcodes,code)
end
function processors.apply(str)
- local p, s = splitter:match(str)
+ local p, s = lpegmatch(splitter,str)
if registered[p] then
return format("\\applyprocessor{%s}{%s}",p,s)
else