From 9b1389520701dbce2bebf451f0e5d719264928ea Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 5 Jun 2012 22:13:43 +0200 Subject: coding style --- mod/tex/context/third/rst/rst_helpers.lua | 36 ++++++++++++++++--------------- 1 file changed, 19 insertions(+), 17 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 9f388c1..d2d7221 100644 --- a/mod/tex/context/third/rst/rst_helpers.lua +++ b/mod/tex/context/third/rst/rst_helpers.lua @@ -11,8 +11,10 @@ local P, R, S, V, match = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.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 +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 local helpers helpers = thirddata.rst_helpers @@ -22,12 +24,12 @@ helpers.cell = {} local utf = unicode.utf8 local utflen = utf.len -local stringstrip = string.strip -local fmt = string.format +local stringstrip = string.strip +local stringformat = string.format function helpers.dbg_writef(...) if helpers.rst_debug then - io.write(fmt(...)) + io.write(stringformat(...)) end end @@ -69,14 +71,14 @@ do [1] = "cells", cells = p.celldelim * (C(V"in_cell") - * (V"matchwidth" * C(V"in_cell")) ^1), + * (V"matchwidth" * C(V"in_cell"))^1), in_cell = p.cellcontent^1 + (p.dash - p.cellcontent)^1, matchwidth = Cmt(C(p.celldelim) * Carg(1), function(s,i,del, layout) local pos = 1 - local lw = layout.widths + local lw = layout.widths for n=1, #lw do pos = pos + lw[n] + 1 if (i - 1) == pos then return true end @@ -166,14 +168,14 @@ end function helpers.table.create(raw) local newtab = {} - newtab.rows = {} + newtab.rows = {} newtab.layout = set_layout(raw[1]) local p = helpers.patterns newtab.resolve_parent = function(row, col, array) local array = array or newtab.rows - local cell = array[row][col] + local cell = array[row][col] local par_row, par_col = row, col if cell.parent then par_row, par_col = newtab.resolve_parent(cell.parent.y, cell.parent.x) @@ -592,9 +594,9 @@ end helpers.string = {} do - -- This grammar inside the function is slightly faster than the same as an upvalue - -- with the value of “width” repeatedly given via lpeg.Carg(). This holds - -- for repeated calls as well. + --- This grammar inside the function is slightly faster than the + --- same as an upvalue with the value of “width” repeatedly given + --- via lpeg.Carg(). This holds for repeated calls as well. local ulen = utflen function helpers.string.wrapat (str, width) local width = width or 65 @@ -608,11 +610,11 @@ do typing = P[[\\type{]] * (1 - P"}")^0 * P"}", typingenv = P[[\\starttyping]] * (1 - P[[\\stoptyping]])^0 * P[[\\stoptyping]], ignore = V"typing" + V"typingenv", - -- the initial whitespace of the “other” pattern must not be - -- enforced (“^1”) as it will break the exceptions (“ignore” - -- pattern)! In general it is better to have the wrapper ignore some - -- valid breaks than to not have it matching some valid strings at - -- all. + --- the initial whitespace of the “other” pattern must not + --- be enforced (“^1”) as it will break the exceptions + --- (“ignore” pattern)! In general it is better to have the + --- wrapper ignore some valid breaks than to not have it + --- matching some valid strings at all. other = Cmt(V"whitespace"^0 * (V"ignore" + (1 - V"whitespace")^1), function(s,i,w) linelength = linelength + ulen(w) return true -- cgit v1.2.3