diff options
author | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2010-09-22 15:36:41 +0200 |
---|---|---|
committer | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2010-09-22 15:36:41 +0200 |
commit | 3afa0dc15d6049aeb109c26e90ad5e42f3f65f46 (patch) | |
tree | 0586e6201307df522dfdfdacde3a95d593f80045 | |
parent | f16f8f54699fbea0f51c54207c10ddeab8b06c6c (diff) | |
download | context-rst-3afa0dc15d6049aeb109c26e90ad5e42f3f65f46.tar.gz |
images accept “alt” as parameter. hash signs in URLs are now escaped
-rw-r--r-- | rst_context.lua | 11 |
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 |