From d7996cadc2e117cc163291abe953dec15cee6826 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 7 Sep 2010 18:32:22 +0200 Subject: revised table implementation. helper module. --- rst_context.lua | 49 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 7 deletions(-) (limited to 'rst_context.lua') 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) -- cgit v1.2.3