Attachment 'chris.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - Textile Parser
4
5 """
6
7 import textile
8 import re
9 from MoinMoin import wikiutil
10
11 RE_WIKI_WIKI_WORD = "([A-Z][a-z]+){2,}(:([A-Z][a-z]+){2,}){0,1}"
12
13 r_colon = re.compile(':')
14 r_wikiwiki = re.compile(RE_WIKI_WIKI_WORD)
15
16 class WikiTextiler(textile.Textiler):
17
18 def __init__(self, text, request):
19 self.request = request
20 textile.Textiler.__init__(self,text)
21
22 def links(self, text):
23 text = textile.Textiler.links(self, text)
24
25 def lookupWikiWikiWord(match):
26 wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, match.group(0))
27 href = wikiutil.join_wiki(wikiurl, wikitail)
28 if wikitag_bad:
29 return '<a href="%s/%s">%s</a>' % (wikiurl, match.group(0), match.group(0))
30 #return 'tag=%s, url=%s, tail=%s, bad=%s' % (wikitag, wikiurl, wikitail, wikitag_bad)
31
32 return '<a href="%s">%s</a>' % (href, match.group(0))
33
34 return r_wikiwiki.sub(lookupWikiWikiWord, text)
35
36 def process(self):
37 return textile.Textiler.process(self)
38
39 #def textil(text, request):
40 # return WikiTextiler(text,request).process()
41
42 class Parser:
43 """
44 Send Textile marked-up page converted to HTML
45 """
46
47 def __init__(self, raw, request, **kw):
48 self.raw = raw
49 self.request = request
50 self.form = request.form
51 self._ = request.getText
52
53 def format(self, formatter):
54 """ Send the text. """
55 #self.request.write(textil(self.raw.expandtabs(),self.request))
56 #self.request.write(textil(self.raw,self.request))
57 self.request.write(textile.textile(self.raw, encoding="utf8", output="utf8"))
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.