From 1cc2bd29d90b5f8e60e3e51976666999dfbeabfa Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 4 Sep 2010 01:07:17 +0200 Subject: generic field lists --- rst_context.lua | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'rst_context.lua') diff --git a/rst_context.lua b/rst_context.lua index 5ca5573..7d0ef28 100644 --- a/rst_context.lua +++ b/rst_context.lua @@ -53,7 +53,14 @@ function rst_context.strong_emphasis (str) end function rst_context.paragraph (str) - return "\n" .. [[\\startparagraph]] .. "\n" .. str .. "\n".. [[\\stopparagraph]] .. "\n" + -- ugly as hell and probably slow too, but the alternative would be lots of + -- concatenation + return string.format([[ + +\\startparagraph +%s +\\stopparagraph +]], str) end function rst_context.literal (str) @@ -312,4 +319,34 @@ function rst_context.deflist_def (str) \\definitiondef{%]] .. str .. [[}]] end +-------------------------------------------------------------------------------- +-- Field lists +-------------------------------------------------------------------------------- + +function rst_context.field_list (str) + return [[ + +\\startfieldlist]] .. str .. [[\\stopfieldlist +]] +end + +function rst_context.field_name (str) + return [[\\fieldname{]] .. str .. [[}]] +end + +function rst_context.field_body (str) + return [[\\fieldbody{]] .. str .. [[}]] +end + +function rst_context.field (tab) + local name, body = tab[1], tab[2] + return string.format([[ + + \\startfield + \\fieldname{%s} + \\fieldbody{%s} + \\stopfield +]], name, body) +end + return rst_context -- cgit v1.2.3