Attachment 'wikispaces.py'
Download 1 # -*- coding: iso-8859-1 -*-
2
3 import re
4 from MoinMoin.parser import wiki
5
6 class Parser(wiki.Parser):
7 """
8 Pre-translate some items from wikispaces to moin
9 """
10 bold = re.compile(r"\*\*([^\n]+?)\*\*")
11 italics = re.compile(r"//([^\n]+?)//")
12 link = re.compile(r"\[\[([^\n]+?)\|([^\n]+?)\]\]")
13 file = re.compile(r"\[\[file:([^\n]+?)(?:\|([^\n]+?))?\]\]")
14 space = re.compile(r" ")
15 sig = re.compile(r"\[\[user:([^\n]+?)\]\]")
16 ul = re.compile(r"\n[*]\s")
17 ol = re.compile(r"\n#\s")
18 def format(self, formatter):
19 """
20 Format
21 """
22 self.raw = self.bold.sub("'''\\1'''",self.raw)
23 self.raw = self.italics.sub("''\\1''",self.raw)
24
25 m = self.file.search(self.raw)
26 while m:
27 url = self.space.sub("_", m.group(1))
28 url = "[http://prospers.org/oldwikifiles/" + url + "]"
29 self.raw = self.raw[:m.start(0)] + url + self.raw[m.end(0):]
30 m = self.file.search(self.raw, m.end(0))
31
32 self.raw = self.link.sub("[\\1 \\2]",self.raw)
33 self.raw = self.sig.sub("-- [\"\\1\"]",self.raw)
34 self.raw = self.ul.sub("\n * ",self.raw)
35 self.raw = self.ol.sub("\n 1. ",self.raw)
36
37 wiki.Parser.format(self, formatter)
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.