summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rst_context.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/rst_context.lua b/rst_context.lua
index 00a8881..5f700f7 100644
--- a/rst_context.lua
+++ b/rst_context.lua
@@ -1146,6 +1146,10 @@ function optional_setups.references ()
local refs = rst_context.collected_references
local crefs = rst_context.context_references
local arefs = rst_context.anonymous_set
+
+ local function urlescape (str)
+ return str:gsub("#", "\\#")
+ end
local function resolve_indirect (r)
if r and r:match(".*_$") then -- pointing elsewhere
@@ -1181,7 +1185,7 @@ function optional_setups.references ()
ref_text = rst_context.anonymous_links[tonumber(arefs[ref_text])]
end
references[#references+1] = string.format([[
-\useURL[__target_%s] [%s] [] [%s] ]], rst_context.whitespace_to_underscore(ref), target, ref_text)
+\useURL[__target_%s] [%s] [] [%s] ]], rst_context.whitespace_to_underscore(ref), urlescape(target), ref_text)
end
end
refsection = refsection .. table.concat(references, "\n")
@@ -1213,6 +1217,7 @@ rst_context.directives.images.keys = {
["width"] = "width",
["size"] = "width",
["caption"] = "caption",
+ ["alt"] = "caption",
["scale"] = "scale",
}
@@ -1298,12 +1303,12 @@ rst_context.directives.image = function(name, data)
\def\RSTsubstitution%s{%%
\placefigure[here]{%s}{\externalfigure[%s]%s}
}
-]], name, inline_parser:match(properties.caption), name, properties.setup)
+]], 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([[
\placefigure[here]{%s}{\externalfigure[%s]%s}
-]], inline_parser:match(properties.caption), data, properties.setup)
+]], rst_context.escape(inline_parser:match(properties.caption)), data, properties.setup)
end
return img
end