summaryrefslogtreecommitdiff
path: root/rst_context.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-07 18:32:22 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-07 18:32:22 +0200
commitd7996cadc2e117cc163291abe953dec15cee6826 (patch)
treef6fc5aedfa5a9e2056140e42b16c92c8e2a1f3ec /rst_context.lua
parentf87e85ad1dd07bfb4f3c07f2571f5af6401733c9 (diff)
downloadcontext-rst-d7996cadc2e117cc163291abe953dec15cee6826.tar.gz
revised table implementation. helper module.
Diffstat (limited to 'rst_context.lua')
-rw-r--r--rst_context.lua49
1 files changed, 42 insertions, 7 deletions
diff --git a/rst_context.lua b/rst_context.lua
index 7603509..fb69dfd 100644
--- a/rst_context.lua
+++ b/rst_context.lua
@@ -467,24 +467,59 @@ function rst_context.table (str)
]]
end
-function rst_context.grid_table (str)
- return [[
+function rst_context.grid_table (tab)
+ local head = [[
\\setupTABLE[c][first] [background=color, backgroundcolor=grey, style=\tt]
-\\setupTABLE[c][each] [frame=off]
-\\setupTABLE[r][each] [frame=off]
+\\setupTABLE[c][each] [frame=on]
+\\setupTABLE[r][each] [frame=on]
\\bTABLE[split=repeat,option=stretch]
\\bTABLEhead
\\bTR
- \\bTH Option \\eTH
- \\bTH Description \\eTH
+ \\bTH first \\eTH
+ \\bTH second \\eTH
+ \\bTH third \\eTH
+ \\bTH fourth \\eTH
\\eTR
\\eTABLEhead
\\bTABLEbody
-]] .. str .. [[
+]]
+ local tail = [[
\\eTABLEbody
\\eTABLE
]]
+ local test = ""
+ for i,r in ipairs(tab.rows) do
+ --if not r.ignore then
+ if r.newrow and not r.ignore then
+ --if r.newrow then
+ --test = test .. string.format("%2s>%s\n", i, #j)
+ --print(i, unpack(j))
+ local row = [[\\bTR]]
+ for n,c in ipairs(r) do
+ if not c.parent then
+ local celltext = c.stripped
+ if c.span.x or c.span.y then
+ local span_exp = "["
+ if c.span.x then
+ span_exp = span_exp .. "nc=" .. c.span.x .. ","
+ end
+ if c.span.y then
+ span_exp = span_exp .. "nr=" .. c.span.y
+ end
+ celltext = span_exp .. "] " .. celltext
+
+ end
+
+ row = row .. "\n " .. [[\\bTC ]] .. celltext .. [[\\eTC]]
+ --print(c.parent)
+ end
+ end
+ test = test .. row .. "\n" .. [[\\eTR]] .. "\n"
+ end
+ end
+ --return head .. test .. tail
+ return head .. test .. tail
end
function rst_context.table_row (tab)