@@ -21,7 +21,7 @@ local stringify = (require "pandoc.utils").stringify
2121-- configure the writer.
2222local meta = PANDOC_DOCUMENT.meta
2323
24−-- Chose the image format based on the value of the
24+-- Choose the image format based on the value of the
2525-- `image_format` meta value.
2626local image_format = meta.image_format
2727 and stringify(meta.image_format)
@@ -45,9 +45,9 @@ local function escape(s, in_attribute)
4545 return '>'
4646 elseif x == '&' then
4747 return '&'
48− elseif x == '"' then
48+ elseif in_attribute and x == '"' then
4949 return '"'
50− elseif x == "'" then
50+ elseif in_attribute and x == "'" then
5151 return '''
5252 else
5353 return x
@@ -141,8 +141,8 @@ function Strikeout(s)
141141 return '<del>' .. s .. '</del>'
142142end
143143
144−function Link(s, src, tit, attr)
145− return "<a href='" .. escape(src,true) .. "' title='" ..
144+function Link(s, tgt, tit, attr)
145+ return "<a href='" .. escape(tgt,true) .. "' title='" ..
146146 escape(tit,true) .. "'>" .. s .. "</a>"
147147end
148148
@@ -271,7 +271,7 @@ end
271271
272272-- Convert pandoc alignment to something HTML can use.
273273-- align is AlignLeft, AlignRight, AlignCenter, or AlignDefault.
274−function html_align(align)
274+local function html_align(align)
275275 if align == 'AlignLeft' then
276276 return 'left'
277277 elseif align == 'AlignRight' then
@@ -286,7 +286,7 @@ end
286286function CaptionedImage(src, tit, caption, attr)
287287 return '<div class="figure">\n<img src="' .. escape(src,true) ..
288288 '" title="' .. escape(tit,true) .. '"/>\n' ..
289− '<p class="caption">' .. caption .. '</p>\n</div>'
289+ '<p class="caption">' .. escape(caption) .. '</p>\n</div>'
290290end
291291
292292-- Caption is a string, aligns is an array of strings,
@@ -357,4 +357,3 @@ meta.__index =
357357 return function() return "" end
358358 end
359359setmetatable(_G, meta)
360−