From 3afa0dc15d6049aeb109c26e90ad5e42f3f65f46 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 22 Sep 2010 15:36:41 +0200 Subject: =?UTF-8?q?images=20accept=20=E2=80=9Calt=E2=80=9D=20as=20paramete?= =?UTF-8?q?r.=20hash=20signs=20in=20URLs=20are=20now=20escaped?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rst_context.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'rst_context.lua') 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 -- cgit v1.2.3