lib/trac-wiki/parser.rb in trac-wiki-0.3.31 vs lib/trac-wiki/parser.rb in trac-wiki-0.3.32
- old
+ new
@@ -222,10 +222,15 @@
end
ret.sub /\n\s+\Z/, ''
},
'!ifdef' => proc { |env| env.at(env.expand_arg(0), nil, false).nil? ? env.expand_arg(2) : env.expand_arg(1) },
'!set' => proc { |env| env[env.expand_arg(0)] = env.expand_arg(1); '' },
+ '!append'=> proc { |env| key = env.expand_arg(0)
+ sep = env.expand_arg(2,'')
+ env[key] = (env[key].nil? ? '' : env[key] + sep ) + env.expand_arg(1);
+ ''
+ },
'!yset' => proc { |env| env[env.expand_arg(0)] = YAML.load(env.arg(1)); '' },
'!sub' => proc { |env| pat = env.expand_arg(1)
pat = Regexp.new(pat[1..-2]) if pat =~ /\A\/.*\/\Z/
env.expand_arg(0).gsub(pat, env.expand_arg(2))
},
@@ -421,11 +426,16 @@
# Create image markup. This
# method can be overridden to generate custom
# markup, for example to add html additional attributes or
# to put divs around the imgs.
def make_image(uri, attrs='')
- @tree.tag(:img, make_image_attrs(uri, attrs))
+ attrs = make_image_attrs(uri, attrs)
+ link = attrs.delete('link')
+
+ @tree.tag_beg(:a, {href: make_explicit_link(link)}) if link
+ @tree.tag(:img, attrs)
+ @tree.tag_end(:a) if link
end
def make_image_attrs(uri, attrs)
a = {src: make_explicit_link(uri)}
style = []
@@ -437,10 +447,10 @@
when /^(right|left|center)/i
a['align'] = escape_url(opt)
when /^(top|bottom|middle)$/i
a['valign'] = escape_url(opt)
when /^link=(.*)$/i
- # pass
+ a['link'] = escape_url($1)
when /^nolink$/i
# pass
when /^(align|valign|border|width|height|alt|title|longdesc|class|id|usemap)=(.*)$/i
a[$1]= escape_url($2)
when /^(margin|margin-(left|right|top|bottom))=(\d+)$/