print '</div></body></html>'
# Macros ------------------------------------------------------------
-def _macro_TitleSearch(*vargs):
- return _macro_search("titlesearch")
-
-def _macro_FullSearch(*vargs):
- return _macro_search("fullsearch")
-
-def _macro_search(type):
- default = ''
- if 'value' in form:
- default = form['value'].value
- return """<form method="get"><input name="%s" size="30" value="%s" /><input type="submit" value="Search" /></form>""" % (type, default)
-
-def _macro_WordIndex(*vargs):
+def _macro_HttpGet(argv):
+ if argv[1] in form:
+ return form[argv[1]].value
+ elif len(argv) > 2:
+ return argv[2] # default value
+ return ''
+
+def _macro_WordIndex(argv):
s = make_index_key()
pages = list(page_list())
map = {}
s = s + '</ul>'
return s
-
-def _macro_TitleIndex(*vargs):
+def _macro_TitleIndex(argv):
s = make_index_key()
pages = list(page_list())
pages.sort()
def __init__(self, raw):
self.raw = raw
self.h_level = 0
- self.in_pre = self.in_table = self.in_li = False
+ self.in_pre = self.in_html = self.in_table = self.in_li = False
self.in_header = True
self.list_indents = []
self.tr_cnt = 0
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)
+ m = re.compile("\<\<([^\s\|\>]+)(?:\s*\|\s*([^\>]+)|)\>\>").match(word)
name = m.group(1)
- param = m.group(2) or None
+ argv = [name]
+ if m.group(2):
+ argv.extend(m.group(2).split('|'))
+ argv = map(str.strip, argv)
macro = globals().get('_macro_' + name)
if macro:
- return macro(name, param)
+ return macro(argv)
else:
- param_str = ''
- if param:
- param_str = param + ' '
- return '<strong class="error">' + name + param_str + '</strong>'
+ return '<strong class="error"><<' + '|'.join(argv) + '>></strong>'
def _hurl_repl(self, word):
m = re.compile("\[\[([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\]\]").match(word)
name = m.group(1)
descr = m.group(2) or name
- macro = globals().get('_macro_' + name)
- if macro:
- return macro(name, descr)
- elif img_re.match(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)
return '<a href="mailto:%s">%s</a>' % (word, word)
def _html_repl(self, word):
+ self.in_html += 1
return word; # Pass through
def _ent_repl(self, s):
+ if self.in_html and s == '>':
+ self.in_html -= 1
+ return '>'
return {'&': '&',
'<': '<',
'>': '>'}[s]
+ r"|(?P<tit>\={2,6})"
+ r"|(?P<br>\\\\)"
+ r"|(?P<rule>^-{3,})"
+ + r"|(?P<hi>\b(FIXME|TODO|DONE)\b)"
# Links
- + r"|(?P<macro><<([^\s\|]+)(?:\s*\|\s*([^\]]+)|)>>)"
+ + r"|(?P<macro>\<\<([^\s\|\>]+)(?:\s*\|\s*([^\>]+)|)\>\>)"
+ r"|(?P<hurl>\[\[([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\]\])"
# Inline HTML
- + r"|(?P<html><(/|)(div|span|iframe)[^<>]*>)"
+ + r"|(?P<html><(/|)(div|span|iframe|form|input))"
+ r"|(?P<ent>[<>&])"
- + r"|(?P<hi>\b(FIXME|TODO|DONE)\b)"
- # Links
+ # Auto links
+ 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