diff options
author | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2010-09-16 22:05:24 +0200 |
---|---|---|
committer | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2010-09-16 22:05:24 +0200 |
commit | eb4c6f0b9ab96b75b944ea6b13c344c58840efb0 (patch) | |
tree | fe201843e92e569a55930401657aabf3c02d8278 | |
parent | c45e21547a2a471ab2147494f505001269374480 (diff) | |
download | context-rst-eb4c6f0b9ab96b75b944ea6b13c344c58840efb0.tar.gz |
moved directives to proper table. there’s a “replace::” directive now.
-rw-r--r-- | rst_context.lua | 52 |
1 files 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 = [[ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |