summaryrefslogtreecommitdiff
path: root/rst_context.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-17 13:59:34 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-17 13:59:34 +0200
commite9a66b9dc2fba26ba6b8feec152511512e6870a6 (patch)
tree18722aff64bc3ae905544d38892204adc4a06d88 /rst_context.lua
parentc3f271b54f49742caad01663c00d2911c31ed8fc (diff)
downloadcontext-rst-e9a66b9dc2fba26ba6b8feec152511512e6870a6.tar.gz
field lists default to 2column table output
Diffstat (limited to 'rst_context.lua')
-rw-r--r--rst_context.lua50
1 files changed, 43 insertions, 7 deletions
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