From e9a66b9dc2fba26ba6b8feec152511512e6870a6 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 17 Sep 2010 13:59:34 +0200 Subject: field lists default to 2column table output --- rst_context.lua | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) (limited to 'rst_context.lua') diff --git a/rst_context.lua b/rst_context.lua index f0fae72..15655a8 100644 --- a/rst_context.lua +++ b/rst_context.lua @@ -223,6 +223,7 @@ end function rst_context.escape (str) str = str:gsub("\\(.)", "%1") + str = str:gsub("&", "\\letterampersand") return str end @@ -473,7 +474,9 @@ function rst_context.paragraph (data) if not data then return "" elseif type(data) == "table" then - str = helpers.string.wrapat(inline_parser:match(table.concat(data, " ")), 65) + print(data,#data,data[1]) + str = #data > 1 and helpers.string.wrapat(inline_parser:match(table.concat(data, " ")), 65) or data[1] + print(str) else str = data end @@ -691,9 +694,10 @@ end -- when using docinfo and, after all, we have .bib files that are portable. function rst_context.field_list (str) + rst_context.addsetups("fieldlist") return [[ -\\startfieldlist]] .. str .. [[\\stopfieldlist +\\startRSTfieldlist]] .. str .. [[\\eTABLEbody\\stopRSTfieldlist ]] end @@ -702,17 +706,15 @@ function rst_context.field_name (str) end function rst_context.field_body (str) - return [[\\fieldbody{]] .. str .. [[}]] + return [[\\fieldbody{]] .. inline_parser:match(str) .. [[}]] end function rst_context.field (tab) local name, body = tab[1], tab[2] return string.format([[ - \\startfield - \\fieldname{%s} - \\fieldbody{%s} - \\stopfield + \\RSTfieldname{%s} + \\RSTfieldbody{%s} ]], name, inline_parser:match(body)) end @@ -1276,4 +1278,38 @@ function optional_setups.breaks () ]] end +function optional_setups.fieldlist () + return [[ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Fieldlists % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def\startRSTfieldlist{% + \bgroup% + \unexpanded\def\RSTfieldname##1{\bTR\bTC ##1\eTC} + \unexpanded\def\RSTfieldbody##1{\bTC ##1\eTC\eTR} +% + \setupTABLE[c][first] [background=color, backgroundcolor=grey, style=\bf] + \setupTABLE[c][2] [align=right] + \setupTABLE[c][each] [frame=off] + \setupTABLE[r][each] [frame=off] + \bTABLE[split=yes,option=stretch] + \bTABLEhead + \bTR + \bTH Field \eTH + \bTH Body \eTH + \eTR + \eTABLEhead + \bTABLEbody +} + +\def\stopRSTfieldlist{% + %\eTABLEbody % doesn't work, temporarily moved to rst_context.field_list() + \eTABLE + \egroup% +} +]] +end + return rst_context -- cgit v1.2.3