[add basic theorem display, improve wikiformat raph.levien@gmail.com**20070101191745] { hunk ./barghest.py 36 + self.wikibase = 'wiki/' hunk ./barghest.py 154 + '.sexp { color: #008 }', hunk ./barghest.py 244 + return hunk ./barghest.py 251 + return hunk ./barghest.py 255 + return hunk ./barghest.py 296 + # We should probably just always prepend the wikibase. + if ctx.wikibase != 'wiki/' and page.find('/') < 0: + page = ctx.wikibase + page + page += '/_thm' # hack hunk ./barghest.py 335 - if re.match('user/', page): + if page.find('/') >= 0: hunk ./barghest.py 338 - pref = 'wiki/' + pref = ctx.wikibase hunk ./barghest.py 341 -def wikilink(ctx, str, exists = None, mstart = 0): +def wikilink(ctx, str, exists = None, ispreblock = False): hunk ./barghest.py 351 - elif re.match('user/', str): - return userlink(ctx, str[5:], body) + elif re.match('user/', link): + return userlink(ctx, link[5:], body) hunk ./barghest.py 365 -def wikigh(ctx, str, mstart): - return '' + htmlquote(str) + '' +def wikigh(ctx, str, ispreblock): + return '' + htmlquote(str) + '' hunk ./barghest.py 368 -def wikipre(ctx, str, mstart): - if mstart == 0: +def wikipre(ctx, str, ispreblock): + if ispreblock: hunk ./barghest.py 393 - special_re = re.compile(r'[<>&\\]|--|(?': '>', '&': '&', '--': '–'} + special_re = re.compile(r''' + [<>&\\] | # HTML entities and backslash + (?': '>', '&': '&', + '--': '–', '---': '—'} hunk ./barghest.py 407 - embeds = {'[': (']', wikilink), '[[': (']]', wikilink), '#': ('#', wikigh), - '{{{': ('}}}', wikipre)} + embeds = {'[': (r'\]', wikilink), '[[': (r'\]\]', wikilink), + '#': (r'#', wikigh), + '{{{': (r'\}\}\}(?!\})', wikipre)} + for open, (close, embedfn) in embeds.items(): + embeds[open] = (re.compile(close), embedfn) hunk ./barghest.py 477 + ispreblock = g == '{{{' and mend == 3 and blank_re.match(line, 3) hunk ./barghest.py 479 - endpos = lines[sline].find(wikiclose, spos) - if g == '{{{' and m.start() == 0 and (endpos != 0 or not blank_re.match(lines[sline], 3)): - endpos = -1 - if endpos >= 0: + end_m = wikiclose.search(lines[sline], spos) + if ispreblock and (end_m or + not blank_re.match(lines[sline], 3)): + end_m = None + if end_m: hunk ./barghest.py 486 - if endpos >= 0: + if end_m: hunk ./barghest.py 488 - str = line[mend:endpos] + str = line[mend:end_m.start()] hunk ./barghest.py 493 - str += lines[sline][:endpos] - rline += embedfn(ctx, str, mstart = m.start()) + str += lines[sline][:end_m.start()] + rline += embedfn(ctx, str, ispreblock = ispreblock) hunk ./barghest.py 497 - pos = endpos + len(wikiclose) - mend = pos + pos = end_m.end() + continue hunk ./barghest.py 614 +def serve_set(ctx): + if len(ctx.path_l) == 1: + label = urllib.unquote_plus(ctx.path_l[0]) + else: + return serve_404(ctx) + + stdpage(ctx, 'Theorem: ' + htmlquote(label)) + response = getwiki(ctx, 'mm/set/%s/_norm' % label) + if response: + content, uname, mtime = response + ctx.wikibase = 'mm/set/' + ctx.write(wikiformat(ctx, content)) + response = getwiki(ctx, 'mm/set/%s/_thm' % label) + if response: + content, uname, mtime = response + ctx.write('
') + ctx.write([htmlquote(line) for line in content.split('\n')]) + ctx.write('') + ctx.wikibase = 'wiki/' + navbar(ctx) + hunk ./barghest.py 663 +servtab['mm'] = {} # hacky, but it'll do for now +servtab['mm']['set'] = serve_set hunk ./barghest.py 679 - break + break }