else:
return '<a href="%s" rel="nofollow" class="external">%s</a>' % (word, word)
+ def _macro_repl(self, word):
+ m = re.compile("<<([^\s\|]+)(?:\s*\|\s*([^\]]+)|)>>").match(word)
+ name = m.group(1)
+ param = m.group(2) or None
+
+ macro = globals().get('_macro_' + name)
+ if macro:
+ return macro(name, param)
+ else:
+ param_str = ''
+ if param:
+ param_str = param + ' '
+ return '<strong class="error">' + name + param_str + '</strong>'
+
def _hurl_repl(self, word):
- m = re.compile("\[\[([^ \t\n\r\f\v\|]+)(?:\s*\|\s*([^\]]+)|)\]\]").match(word)
+ m = re.compile("\[\[([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\]\]").match(word)
name = m.group(1)
descr = m.group(2) or name
+ r"|(?P<tit>\={2,6})"
+ r"|(?P<br>\\\\)"
+ r"|(?P<rule>^-{3,})"
+
+ # Links
+ + r"|(?P<macro><<([^\s\|]+)(?:\s*\|\s*([^\]]+)|)>>)"
+ + r"|(?P<hurl>\[\[([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\]\])"
+
+ # Inline HTML
+ r"|(?P<html><(/|)(div|span|iframe)[^<>]*>)"
+ r"|(?P<ent>[<>&])"
+ r"|(?P<hi>\b(FIXME|TODO|DONE)\b)"
# Links
- + r"|(?P<img>\b[a-zA-Z0-9_-]+\.(png|gif|jpg|jpeg|bmp))"
- + r"|(?P<word>\b(?:[A-Z][a-z]+){2,}\b)"
- + r"|(?P<hurl>\[\[([^ \s\|]+)(?:\s*\|\s*([^\]]+)|)\]\])"
- + r"|(?P<url>(http|https|ftp|mailto)\:[^\s'\"]+\S)"
- + r"|(?P<email>[-\w._+]+\@[\w.-]+)"
+ + r"|(?P<img>\b[a-zA-Z0-9_-]+\.(png|gif|jpg|jpeg|bmp))" # LEGACY
+ + r"|(?P<word>\b(?:[A-Z][a-z]+){2,}\b)" # LEGACY
+ + r"|(?P<url>(http|https|ftp|mailto)\:[^\s'\"]+\S)" # LEGACY
+ + r"|(?P<email>[-\w._+]+\@[\w.-]+)" # LEGACY
# Lists, divs, spans
+ r"|(?P<li>^\s+[\*#] +)"
+ r"|(?P<pre>\{\{\{|\s*\}\}\})"
- + r"|(?P<hurl>\{\{([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\}\})"
+ + r"|(?P<inl>\{\{([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\}\})" #TODO
# Tables
+ r"|(?P<tr>^\s*\|\|(=|)\s*)"