Attachment 'textil.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 = super(WikiTextiler, self).links(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 super(WikiTextiler, self).process()
  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))

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.
  • [get | view] (2006-02-16 14:59:57, 14.6 KB) [[attachment:Calendar-20060216.py]]
  • [get | view] (2007-05-28 09:42:03, 2.7 KB) [[attachment:ExcelPastedTable.py]]
  • [get | view] (2005-04-12 19:22:18, 6.0 KB) [[attachment:Gantt-1.3.3-2.py]]
  • [get | view] (2007-03-24 02:05:26, 3.9 KB) [[attachment:Literate_parser-0.7_Moin-1.3.tgz]]
  • [get | view] (2007-03-24 02:08:08, 4.8 KB) [[attachment:Literate_parser-0.7_Moin-1.3.zip]]
  • [get | view] (2005-03-11 13:50:49, 12.3 KB) [[attachment:MySQL.py]]
  • [get | view] (2005-09-11 08:09:44, 1.6 KB) [[attachment:SortText-1.3.5-1.py]]
  • [get | view] (2005-11-21 08:40:10, 2.8 KB) [[attachment:Sorter-1.3.py]]
  • [get | view] (2005-06-02 13:02:06, 1.2 KB) [[attachment:colorer.py]]
  • [get | view] (2006-01-04 16:10:31, 0.6 KB) [[attachment:gettext.py]]
  • [get | view] (2004-10-19 13:05:05, 0.7 KB) [[attachment:html-parser-1.2.py]]
  • [get | view] (2005-02-17 10:46:56, 0.6 KB) [[attachment:html.py]]
  • [get | view] (2005-12-06 21:09:48, 1.3 KB) [[attachment:matlab.py]]
  • [get | view] (2005-01-20 07:42:34, 0.4 KB) [[attachment:nocamelcase.py]]
  • [get | view] (2005-11-28 16:55:23, 2.3 KB) [[attachment:php-1.3.4-1]]
  • [get | view] (2005-12-18 22:36:37, 15.0 KB) [[attachment:sctable-1.3.5-4.py]]
  • [get | view] (2004-12-31 04:41:23, 1.6 KB) [[attachment:textil.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.