summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/x-ct.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/x-ct.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/x-ct.lua79
1 files changed, 31 insertions, 48 deletions
diff --git a/Master/texmf-dist/tex/context/base/x-ct.lua b/Master/texmf-dist/tex/context/base/x-ct.lua
index 222a127cec6..2dee985c329 100644
--- a/Master/texmf-dist/tex/context/base/x-ct.lua
+++ b/Master/texmf-dist/tex/context/base/x-ct.lua
@@ -6,11 +6,12 @@ if not modules then modules = { } end modules ['x-ct'] = {
license = "see context related readme files"
}
-local xmlsprint, xmlfilter, xmlcollected = xml.sprint, xml.filter, xml.collected
-local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes
+-- needs testing
+
+local xmlsprint, xmlcprint, xmlfilter, xmlcollected = xml.sprint, xml.cprint, xml.filter, xml.collected
local format, concat, rep, find = string.format, table.concat, string.rep, string.find
-lxml.context = { }
+moduledata.ct = moduledata.ct or { }
local halignments = {
left = 'l',
@@ -23,16 +24,27 @@ local halignments = {
justify = '',
}
+local templates = { }
+
+function moduledata.ct.registertabulatetemplate(name,str)
+ templates[name] = str
+end
+
local function roottemplate(root)
local rt = root.at.template
if rt then
- if not find(rt,"|") then
- rt = gsub(rt,",","|")
+ local template = templates[rt]
+ if template then
+ return template
+ else
+ if not find(rt,"|") then
+ rt = gsub(rt,",","|")
+ end
+ if not find(rt,"^|") then rt = "|" .. rt end
+ if not find(rt,"|$") then rt = rt .. "|" end
+ return rt
end
- if not find(rt,"^|") then rt = "|" .. rt end
- if not find(rt,"|$") then rt = rt .. "|" end
end
- return rt
end
local function specifiedtemplate(root,templatespec)
@@ -69,7 +81,7 @@ end
local defaulttemplate = "|l|p|"
-function lxml.context.tabulate(root,namespace)
+function moduledata.ct.tabulate(root,namespace)
if not root then
return
else
@@ -79,7 +91,7 @@ function lxml.context.tabulate(root,namespace)
local prefix = (namespace or "context") .. ":"
local templatespec = "/" .. prefix .. "template" .. "/" .. prefix .. "column"
- local bodyrowspec = "/" .. prefix .. "body" .. "/" .. prefix .. "row"
+ local bodyrowspec = "/" .. prefix .. "body" .. "/" .. prefix .. "row"
local cellspec = "/" .. prefix .. "cell"
local template =
@@ -90,22 +102,6 @@ function lxml.context.tabulate(root,namespace)
-- todo: head and foot
---~ lxml.directives.before(root,'cdx')
---~ texsprint(ctxcatcodes, "\\bgroup")
---~ lxml.directives.setup(root,'cdx')
---~ texsprint(ctxcatcodes, format("\\starttabulate[%s]",template))
---~ for e in xmlcollected(root,bodyrowspec) do
---~ texsprint(ctxcatcodes, "\\NC ")
---~ for e in xmlcollected(e,cellspec) do
---~ texsprint(xml.text(e)) -- use some xmlprint
---~ texsprint(ctxcatcodes, "\\NC")
---~ end
---~ texsprint(ctxcatcodes, "\\NR")
---~ end
---~ texsprint(ctxcatcodes, "\\stoptabulate")
---~ texsprint(ctxcatcodes, "\\egroup")
---~ lxml.directives.after(root,'cdx')
-
local NC, NR = context.NC, context.NR
lxml.directives.before(root,'cdx')
@@ -115,7 +111,7 @@ function lxml.context.tabulate(root,namespace)
for e in xmlcollected(root,bodyrowspec) do
NC()
for e in xmlcollected(e,cellspec) do
- texsprint(xml.text(e)) -- test: xmlcprint(e)
+ xmlcprint(e)
NC()
end
NR()
@@ -126,7 +122,7 @@ function lxml.context.tabulate(root,namespace)
end
-function lxml.context.combination(root,namespace)
+function moduledata.ct.combination(root,namespace)
if not root then
return
@@ -147,33 +143,20 @@ function lxml.context.combination(root,namespace)
end
local template = format("%s*%s", nx or 1, ny or 1)
- -- todo: alignments
-
---~ lxml.directives.before(root,'cdx')
---~ texsprint(ctxcatcodes, "\\bgroup")
---~ lxml.directives.setup(root,'cdx')
---~ texsprint(ctxcatcodes, "\\startcombination[",template,"]")
---~ for e in xmlcollected(root,pairspec) do
---~ texsprint(ctxcatcodes,"{")
---~ xmlfilter(e,contentspec)
---~ texsprint(ctxcatcodes,"}{")
---~ xmlfilter(e,captionspec)
---~ texsprint(ctxcatcodes,"}")
---~ end
---~ texsprint(ctxcatcodes, "\\stopcombination")
---~ texsprint(ctxcatcodes, "\\egroup")
---~ lxml.directives.after(root,'cdx')
-
lxml.directives.before(root,'cdx')
context.bgroup()
lxml.directives.setup(root,'cdx')
context.startcombination { template }
for e in xmlcollected(root,pairspec) do
- texsprint(ctxcatcodes,"{")
+ -- context.combination(
+ -- function() xmlfilter(e,contentspec) end,
+ -- function() xmlfilter(e,captionspec) end
+ -- )
+ context("{")
xmlfilter(e,contentspec)
- texsprint(ctxcatcodes,"}{")
+ context("}{")
xmlfilter(e,captionspec)
- texsprint(ctxcatcodes,"}")
+ context("}")
end
context.stopcombination()
context.egroup()