file_re = re.compile(r"^\b([A-Za-z0-9_\-][A-Za-z0-9_\.\-/]*)\b$")
img_re = re.compile(r"^.*\.(png|gif|jpg|jpeg)$", re.IGNORECASE)
url_re = re.compile(r"^[a-z]{3,8}://[^\s'\"]+\S$")
+link_re = re.compile("(?:\[\[|{{)([^\s\|]+)(?:\s*\|\s*([^\]]+)|)(?:\]\]|}})")
title_done = False
return '<strong class="error"><<' + '|'.join(argv) + '>></strong>'
def _hurl_repl(self, word):
- m = re.compile("\[\[([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\]\]").match(word)
+ m = link_re.match(word)
name = m.group(1)
descr = m.group(2) or name
if img_re.match(name):
- name = relative_url(name)
- # The "extthumb" nonsense works around a limitation of the HTML block model
- return '<div class="extthumb"><div class="thumb"><a href="%s"><img border="0" src="%s" alt="%s" /></a><div class="caption">%s</div></div></div>' % (name, name, descr, descr)
+ # DEPRECATED SYNTAX: use {{foo.jpg|descr}} instead
+ _inl_repl(self, word)
else:
if img_re.match(descr):
descr = '<img border="0" src="' + descr + '" />'
return link_tag(name, descr, 'wikilink')
+ def _inl_repl(self, word):
+ m = link_re.match(word)
+ name = m.group(1)
+ descr = m.group(2) or name
+ name = relative_url(name)
+ if descr:
+ # The "extthumb" nonsense works around a limitation of the HTML block model
+ return '<div class="extthumb"><div class="thumb"><a href="%s"><img border="0" src="%s" alt="%s" /></a><div class="caption">%s</div></div></div>' % (name, name, descr, descr)
+ else:
+ return '<a href="%s"><img border="0" src="%s" /></a>' % (name, name)
+
def _email_repl(self, word):
return '<a href="mailto:%s">%s</a>' % (word, word)