From eb4c6f0b9ab96b75b944ea6b13c344c58840efb0 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 16 Sep 2010 22:05:24 +0200 Subject: =?UTF-8?q?moved=20directives=20to=20proper=20table.=20there?= =?UTF-8?q?=E2=80=99s=20a=20=E2=80=9Creplace::=E2=80=9D=20directive=20now.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rst_context.lua | 52 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/rst_context.lua b/rst_context.lua index 00b93f5..9112786 100644 --- a/rst_context.lua +++ b/rst_context.lua @@ -1121,28 +1121,33 @@ function optional_setups.references () return refsection end -function optional_setups.substitutions () - local images_done = {} +-------------------------------------------------------------------------------- +-- Directives for use with |substitutions| +-------------------------------------------------------------------------------- - local directives = {} - directives.image = function(name, data) - local img = "" - if not images_done[name] then - img = img .. string.format([[ +rst_context.directives = {} +rst_context.directives.images_done = {} + +rst_context.directives.image = function(name, data) + local img = "" + local images_done = rst_context.directives.images_done + if not images_done[name] then + img = img .. string.format([[ \useexternalfigure[%s][%s][] ]], name, data) - end - img = img .. string.format([[ + images_done[name] = true + end + img = img .. string.format([[ \def\RSTsubstitution%s{ \placefigure[here]{%s}{\externalfigure[%s]} } ]], name, name, name) - return img - end + return img +end - directives.ctx = function(name, data) - local ctx = string.format([[ +rst_context.directives.ctx = function(name, data) + local ctx = string.format([[ \startbuffer[%s] %s @@ -1151,11 +1156,11 @@ function optional_setups.substitutions () \getbuffer[%s] } ]], name, data, name, name) - return ctx - end + return ctx +end - directives.lua = function(name, data) - local luacode = string.format([[ +rst_context.directives.lua = function(name, data) + local luacode = string.format([[ \startbuffer[%s] \startluacode @@ -1166,9 +1171,18 @@ function optional_setups.substitutions () \getbuffer[%s]%% } ]], name, data, name, name) - return luacode - end + return luacode +end + +rst_context.directives.replace = function(name, data) + return string.format([[ +\def\RSTsubstitution%s{%s} +]], name, data) +end + +function optional_setups.substitutions () + local directives = rst_context.directives local substitutions = [[ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- cgit v1.2.3