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_context.lua | 48 ++++++++++++++++--------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'mod/tex/context/third/rst/rst_context.lua') diff --git a/mod/tex/context/third/rst/rst_context.lua b/mod/tex/context/third/rst/rst_context.lua index 823bd9b..3faa66a 100644 --- a/mod/tex/context/third/rst/rst_context.lua +++ b/mod/tex/context/third/rst/rst_context.lua @@ -8,11 +8,11 @@ -------------------------------------------------------------------------------- -- --- TODO --- - Find an appropriate way to handle generic tables irrespective of the grid --- settings. The problem is: --- http://archive.contextgarden.net/message/20100912.112605.8a1aaf13.en.html --- Seems we'll have to choose either the grid or split tables as default. Not --- good. +--- Find an appropriate way to handle generic tables irrespective of the grid +--- settings. The problem is: +--- http://archive.contextgarden.net/message/20100912.112605.8a1aaf13.en.html +--- Seems we'll have to choose either the grid or split tables as default. Not +--- good. local helpers = helpers or thirddata and thirddata.rst_helpers @@ -26,8 +26,10 @@ local iowrite = io.write local dbg_write = helpers.dbg_writef -local C, Cb, Cc, Cg, Cmt, Cp, Cs, Ct, P, R, S, V, match = - lpeg.C, lpeg.Cb, lpeg.Cc, lpeg.Cg, lpeg.Cmt, lpeg.Cp, lpeg.Cs, lpeg.Ct, lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.match +local C, Cb, Cc, Cg, Cmt, Cp, + Cs, Ct, P, R, S, V, match + = lpeg.C, lpeg.Cb, lpeg.Cc, lpeg.Cg, lpeg.Cmt, lpeg.Cp, + lpeg.Cs, lpeg.Ct, lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.match -- This one should ignore escaped spaces. do @@ -42,8 +44,8 @@ do return stripper:match(str) or "" end end -local stringstrip = string.strip -local fmt = string.format +local stringstrip = string.strip +local stringformat = string.format local err = function(str) if str then @@ -106,8 +108,8 @@ do end end --- So we can use crefs[n][2] to refer to the place where the reference was --- created. +--- So we can use crefs[n][2] to refer to the place where the reference was +--- created. local function get_context_reference (str) local crefs = rst_context.context_references local srefs = rst_context.structure_references @@ -164,9 +166,9 @@ rst_context.roles.color = function(color, str) local definition = color:match("^color_(.+)$") if definition:match("^rgb_") then -- assume rgb local rgb = p.rgbvalues:match(definition) - definition = fmt([[r=%s,g=%s,b=%s]], rgb[1], rgb[2], rgb[3]) + definition = stringformat([[r=%s,g=%s,b=%s]], rgb[1], rgb[2], rgb[3]) end - return fmt([[\\colored[%s]{%s}]], definition, str) + return stringformat([[\\colored[%s]{%s}]], definition, str) end -------------------------------------------------------------------------------- @@ -195,7 +197,7 @@ end -- wrong if you can! Or go tell those digital publishers and their willing -- subordinates, the authors, who think they can save a few pennys, -- substituting the typesetter and editor by some fancy software. Keep in mind --- that zapf.tex is not just random dummy text. Now, where was I? +-- that zapf.tex is not just random dummy text. function rst_context.roles.ctsh(str) -- shorthand rst_context.addsetups("citator") @@ -283,7 +285,7 @@ function rst_context.anon_reference (str) str = str:match("^`?([^`]+)`?__$") rst_context.anonymous_links[#rst_context.anonymous_links+1] = str link = "__target_anon_" .. #rst_context.anonymous_links - return fmt([[\\RSTchoosegoto{%s}{%s}]], link, str) + return stringformat([[\\RSTchoosegoto{%s}{%s}]], link, str) end local whitespace = S" \n\t\v" @@ -642,7 +644,7 @@ function rst_context.paragraph (data) else str = data end - return fmt([[ + return stringformat([[ \\startparagraph %s @@ -692,7 +694,7 @@ function rst_context.section (...) -- TODO general cleanup; move validity ref = get_context_reference (str) - str = fmt("\n\\\\%s[%s]{%s}\n", sectionlevels[level], ref, str) + str = stringformat("\n\\\\%s[%s]{%s}\n", sectionlevels[level], ref, str) else return [[{\\bf fix your sectioning!}\\endgraf}]] end @@ -815,7 +817,7 @@ function rst_context.bullet_item (tab) -- just leave it alone elseif helpers.list.greater(itemtype, li[current_itemdepth]) then local itemnum = tonumber(stringstrip(itemtype)) or helpers.list.get_decimal(itemtype) - result = result .. fmt([[ + result = result .. stringformat([[ \\setnumber[itemgroup:itemize]{%s} ]], itemnum) end @@ -898,7 +900,7 @@ end function rst_context.field (tab) local name, body = tab[1], tab[2] - return fmt([[ + return stringformat([[ \\RSTfieldname{%s} \\RSTfieldbody{%s} @@ -910,7 +912,7 @@ function rst_context.line_comment (str) end function rst_context.block_comment (str) - return fmt([[ + return stringformat([[ \iffalse %% start block comment %s\fi %% stop block comment @@ -938,7 +940,7 @@ function rst_context.option_list (str) end function rst_context.option_item (tab) - return fmt([[\\bTR\\bTC %s \\eTC\\bTC %s \\eTC\\eTR + return stringformat([[\\bTR\\bTC %s \\eTC\\bTC %s \\eTC\\eTR ]], tab[1], tab[2]) end @@ -1164,7 +1166,7 @@ function rst_context.simple_table(tab) dbg_write("%7s | ", cell.content) local celltext = inline_parser:match(cell.content) if cell.span then - head = head .. fmt([=[\\bTH[nc=%s]%s\\eTH]=], cell.span.x, celltext or "") + head = head .. stringformat([=[\\bTH[nc=%s]%s\\eTH]=], cell.span.x, celltext or "") else head = head .. [[\\bTH ]] .. celltext .. [[\\eTH]] end @@ -1203,7 +1205,7 @@ function rst_context.simple_table(tab) dbg_write("%7s | ", cell.content) local celltext = inline_parser:match(cell.content) if cell.span then - body = body .. fmt([=[\\bTC[nc=%s]%s\\eTC]=], cell.span.x, celltext or "") + body = body .. stringformat([=[\\bTC[nc=%s]%s\\eTC]=], cell.span.x, celltext or "") else body = body .. [[\\bTC ]] .. celltext .. [[\\eTC]] end -- cgit v1.2.3