Support image links
authorBernardo Innocenti <bernie@codewiz.org>
Mon, 17 Dec 2007 09:41:29 +0000 (10:41 +0100)
committerBernardo Innocenti <bernie@codewiz.org>
Mon, 17 Dec 2007 09:41:29 +0000 (10:41 +0100)
geekigeeki.py

index 56d71f156f6b62984397e1b91d66ce73427b658e..83b6142a0a82d6cd457c53baf76154dccbb1eb89 100755 (executable)
@@ -389,12 +389,16 @@ class PageFormatter:
             return apply(macro, (name, descr))
         elif img_re.match(name):
             return '<a href="%s"><img border="0" src="%s" alt="%s" /></a>' % (name, name, descr)
-        elif url_re.match(name):
-            return '<a href="%s" rel="nofollow" class="external">%s</a>' % (name, descr)
-        elif name.startswith('/'):
-            return '<a href="%s">%s</a>' % (name, descr)
         else:
-            return link_tag(name, descr, 'wikilink')
+            if img_re.match(descr):
+                descr = '<img border="0" src="' + descr + '" />'
+
+            if url_re.match(name):
+                return '<a href="%s" rel="nofollow" class="external">%s</a>' % (name, descr)
+            elif name.startswith('/'):
+                return '<a href="%s">%s</a>' % (name, descr)
+            else:
+                return link_tag(name, descr, 'wikilink')
 
     def _email_repl(self, word):
         return '<a href="mailto:%s">%s</a>' % (word, word)