summaryrefslogtreecommitdiff
path: root/mod/tex/context/third/rst/rst_directives.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <megas.kapaneus@gmail.com>2011-08-28 14:30:54 +0200
committerPhilipp Gesang <megas.kapaneus@gmail.com>2011-08-28 14:30:54 +0200
commit001738e26e1b841a4042b3597ba28d9c3d04aef6 (patch)
tree6e1898eed40ac96a7677206109e6395ddd98f619 /mod/tex/context/third/rst/rst_directives.lua
parent258db63993a69f76301faefa7e7a5727f23d2614 (diff)
downloadcontext-rst-001738e26e1b841a4042b3597ba28d9c3d04aef6.tar.gz
fixed solitary substitution bug (reported by Philipp A.)
Diffstat (limited to 'mod/tex/context/third/rst/rst_directives.lua')
-rw-r--r--mod/tex/context/third/rst/rst_directives.lua33
1 files changed, 18 insertions, 15 deletions
diff --git a/mod/tex/context/third/rst/rst_directives.lua b/mod/tex/context/third/rst/rst_directives.lua
index 4a2b7e3..3bc4166 100644
--- a/mod/tex/context/third/rst/rst_directives.lua
+++ b/mod/tex/context/third/rst/rst_directives.lua
@@ -14,9 +14,12 @@ local helpers = helpers or thirddata and thirddata.rst_helpers
-- Directives for use with |substitutions|
--------------------------------------------------------------------------------
-local rst_directives = { }
+local rst_directives = { }
thirddata.rst_directives = rst_directives
-local rst_context = thirddata.rst
+local rst_context = thirddata.rst
+
+local stringstrip = string.strip
+local fmt = string.format
rst_directives.anonymous = 0
rst_directives.images = {}
@@ -94,7 +97,7 @@ rst_directives.image = function(name, data)
end
properties[key] = val
else
- processed = processed .. (str and str ~= "" and string.strip(str))
+ processed = processed .. (str and str ~= "" and stringstrip(str))
end
end
end
@@ -105,19 +108,19 @@ rst_directives.image = function(name, data)
local images_done = rd.images.done
if not anon then
if not images_done[name] then
- img = img .. string.format([[
+ img = img .. fmt([[
\useexternalfigure[%s][%s][]
]], name, data)
images_done[name] = true
end
- img = img .. string.format([[
+ img = img .. fmt([[
\def\RSTsubstitution%s{%%
\placefigure[here]{%s}{\externalfigure[%s]%s}
}
]], name, rst_context.escape(inline_parser:match(properties.caption)), name, properties.setup)
else -- image won't be referenced but used instantly
- img = img .. string.format([[
+ img = img .. fmt([[
\placefigure[here]{%s}{\externalfigure[%s]%s}
]], rst_context.escape(inline_parser:match(properties.caption)), data, properties.setup)
@@ -142,7 +145,7 @@ rst_directives.caution = function(raw)
end
end
text = rst_context.escape(helpers.string.wrapat(inline_parser:match(text)))
- return string.format([[
+ return fmt([[
\startRSTcaution
%s
\stopRSTcaution
@@ -166,7 +169,7 @@ rst_directives.danger = function(raw)
end
end
text = rst_context.escape(helpers.string.wrapat(inline_parser:match(text)))
- return string.format([[
+ return fmt([[
\startRSTdanger
%s
\stopRSTdanger
@@ -177,9 +180,9 @@ end
rst_directives.DANGER = function(addendum)
local result = ""
for _,str in ipairs(addendum) do
- result = result .. (string.strip(str))
+ result = result .. (stringstrip(str))
end
- return string.format([[
+ return fmt([[
%% The Rabbit of Caerbannog
\startlinecorrection
@@ -210,12 +213,12 @@ rst_directives.DANGER = function(addendum)
end
rst_directives.mp = function(name, data)
- local mpcode = string.format([[
+ local mpcode = fmt([[
\startreusableMPgraphic{%s}
%s
\stopreusableMPgraphic
]], name, data)
- mpcode = mpcode .. string.format([[
+ mpcode = mpcode .. fmt([[
\def\RSTsubstitution%s{%%
\reuseMPgraphic{%s}%%
}
@@ -224,7 +227,7 @@ rst_directives.mp = function(name, data)
end
rst_directives.ctx = function(name, data)
- local ctx = string.format([[
+ local ctx = fmt([[
\startbuffer[%s]
%s\stopbuffer
@@ -236,7 +239,7 @@ rst_directives.ctx = function(name, data)
end
rst_directives.lua = function(name, data)
- local luacode = string.format([[
+ local luacode = fmt([[
\startbuffer[%s]
\startluacode
@@ -251,7 +254,7 @@ rst_directives.lua = function(name, data)
end
rst_directives.replace = function(name, data)
- return string.format([[
+ return fmt([[
\def\RSTsubstitution%s{%s}
]], name, data)