summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/third/rst/rst_directives.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/third/rst/rst_directives.lua')
-rw-r--r--Master/texmf-dist/tex/context/third/rst/rst_directives.lua43
1 files changed, 23 insertions, 20 deletions
diff --git a/Master/texmf-dist/tex/context/third/rst/rst_directives.lua b/Master/texmf-dist/tex/context/third/rst/rst_directives.lua
index 96eaf591fa5..78b184c91a4 100644
--- a/Master/texmf-dist/tex/context/third/rst/rst_directives.lua
+++ b/Master/texmf-dist/tex/context/third/rst/rst_directives.lua
@@ -3,8 +3,8 @@
-- FILE: rst_directives.lua
-- USAGE: called by rst_parser.lua
-- DESCRIPTION: Complement to the reStructuredText parser
--- AUTHOR: Philipp Gesang (Phg), <megas.kapaneus@gmail.com>
--- CHANGED: 2011-08-28 13:47:00+0200
+-- AUTHOR: Philipp Gesang (Phg), <phg42.2a@gmail.com>
+-- CHANGED: 2012-06-05 22:17:51+0200
--------------------------------------------------------------------------------
--
@@ -18,8 +18,8 @@ local rst_directives = { }
thirddata.rst_directives = rst_directives
local rst_context = thirddata.rst
-local stringstrip = string.strip
-local fmt = string.format
+local stringstrip = string.strip
+local stringformat = string.format
rst_directives.anonymous = 0
rst_directives.images = {}
@@ -108,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 .. fmt([[
+ img = img .. stringformat([[
\useexternalfigure[%s][%s][]
]], name, data)
images_done[name] = true
end
- img = img .. fmt([[
+ img = img .. stringformat([[
\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 .. fmt([[
+ img = img .. stringformat([[
\placefigure[here]{%s}{\externalfigure[%s]%s}
]], rst_context.escape(inline_parser:match(properties.caption)), data, properties.setup)
@@ -145,7 +145,7 @@ rst_directives.caution = function(raw)
end
end
text = rst_context.escape(helpers.string.wrapat(inline_parser:match(text)))
- return fmt([[
+ return stringformat([[
\startRSTcaution
%s
\stopRSTcaution
@@ -169,7 +169,7 @@ rst_directives.danger = function(raw)
end
end
text = rst_context.escape(helpers.string.wrapat(inline_parser:match(text)))
- return fmt([[
+ return stringformat([[
\startRSTdanger
%s
\stopRSTdanger
@@ -182,7 +182,7 @@ rst_directives.DANGER = function(addendum)
for _,str in ipairs(addendum) do
result = result .. (stringstrip(str))
end
- return fmt([[
+ return stringformat([[
%% The Rabbit of Caerbannog
\startlinecorrection
@@ -213,12 +213,12 @@ rst_directives.DANGER = function(addendum)
end
rst_directives.mp = function(name, data)
- local mpcode = fmt([[
+ local mpcode = stringformat([[
\startreusableMPgraphic{%s}
%s
\stopreusableMPgraphic
]], name, data)
- mpcode = mpcode .. fmt([[
+ mpcode = mpcode .. stringformat([[
\def\RSTsubstitution%s{%%
\reuseMPgraphic{%s}%%
}
@@ -226,28 +226,31 @@ rst_directives.mp = function(name, data)
return mpcode
end
+--- There’s an issue with buffers leaving trailing spaces due to their
+--- implementation.
+--- http://archive.contextgarden.net/message/20111108.175913.1d994624.en.html
rst_directives.ctx = function(name, data)
- local ctx = fmt([[
+ local ctx = stringformat([[
-\startbuffer[%s]
+\startbuffer[%s]%%
%s\stopbuffer
\def\RSTsubstitution%s{%%
- \getbuffer[%s]%%
+ \getbuffer[%s]\removeunwantedspaces%%
}
]], name, data, name, name)
return ctx
end
rst_directives.lua = function(name, data)
- local luacode = fmt([[
+ local luacode = stringformat([[
-\startbuffer[%s]
+\startbuffer[%s]%%
\startluacode
%s
\stopluacode
\stopbuffer
\def\RSTsubstitution%s{%%
- \getbuffer[%s]%%
+ \getbuffer[%s]\removeunwantedspaces%%
}
]], name, data, name, name)
return luacode
@@ -270,7 +273,7 @@ rst_directives.math = function (name, data)
i = i + 1
end
end
- return fmt([[
+ return stringformat([[
\startformula
%s
\stopformula
@@ -282,7 +285,7 @@ end
--------------------------------------------------------------------------------
rst_directives.replace = function(name, data)
- return fmt([[
+ return stringformat([[
\def\RSTsubstitution%s{%s}
]], name, data)