From 78d44502d0e4dc5179b703189da54bc3dfe0d306 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 4 May 2011 17:44:12 +0200 Subject: confirming to Lua module namespace; alternate code from Wolfgang (resting for now) --- mod/tex/context/third/rst/rst_helpers.lua | 42 ++++++++++++++++--------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'mod/tex/context/third/rst/rst_helpers.lua') diff --git a/mod/tex/context/third/rst/rst_helpers.lua b/mod/tex/context/third/rst/rst_helpers.lua index f081559..e6a886b 100644 --- a/mod/tex/context/third/rst/rst_helpers.lua +++ b/mod/tex/context/third/rst/rst_helpers.lua @@ -1,11 +1,10 @@ #!/usr/bin/env texlua -------------------------------------------------------------------------------- -- FILE: rst_helpers.lua --- USAGE: ./rst_helpers.lua +-- USAGE: called by rst_parser.lua -- DESCRIPTION: Complement to the reStructuredText parser -- AUTHOR: Philipp Gesang (Phg), --- VERSION: 1.0 --- CREATED: 07/09/10 01:03:08 CEST +-- CREATED: 2011-05-04 17:41:59+0200 -------------------------------------------------------------------------------- -- @@ -16,17 +15,21 @@ local P, R, S, V, match local C, Carg, Cb, Cc, Cg, Cmt, Cp, Cs, Ct = lpeg.C, lpeg.Carg, lpeg.Cb, lpeg.Cc, lpeg.Cg, lpeg.Cmt, lpeg.Cp, lpeg.Cs, lpeg.Ct -helpers = helpers or {} +local helpers +if not context then + helpers = helpers or {} +else + helpers = thirddata.rst_helpers +end helpers.table = {} helpers.cell = {} function helpers.dbg_writef(...) - if helpers_debug == true then + if helpers.rst_debug then io.write(string.format(...)) end end ---helpers.dbg_write = dbg_write local dbg_write = helpers.dbg_writef helpers.patterns = {} @@ -160,7 +163,6 @@ local function set_layout (line) return layout end -helpers_debug = true function helpers.table.create(raw) local newtab = {} newtab.rows = {} @@ -295,18 +297,18 @@ function helpers.table.create(raw) newtab.__init() - newtab.__draw_debug = function() - for nr, row in ipairs(newtab.rows) do - for nc, cell in ipairs(row) do - local field = cell.variant:sub(1,7) - if cell.parent then - field = field .. string.format(" %s,%2s",cell.parent.x, cell.parent.y) - end - dbg_write("%12s | ", field) - end - dbg_write("\n") - end - end + --newtab.__draw_debug = function() + --for nr, row in ipairs(newtab.rows) do + --for nc, cell in ipairs(row) do + --local field = cell.variant:sub(1,7) + --if cell.parent then + --field = field .. string.format(" %s,%2s",cell.parent.x, cell.parent.y) + --end + --dbg_write("%12s | ", field) + --end + --dbg_write("\n") + --end + --end return newtab end @@ -628,5 +630,5 @@ do end end -return helpers +--return helpers -- cgit v1.2.3