summaryrefslogtreecommitdiffabout
path: root/wikitrans/wikimarkup.py
Unidiff
Diffstat (limited to 'wikitrans/wikimarkup.py') (more/less context) (show whitespace changes)
-rw-r--r--wikitrans/wikimarkup.py46
1 files changed, 24 insertions, 22 deletions
diff --git a/wikitrans/wikimarkup.py b/wikitrans/wikimarkup.py
index d199335..0ce0e15 100644
--- a/wikitrans/wikimarkup.py
+++ b/wikitrans/wikimarkup.py
@@ -183,34 +183,13 @@ class WikiMarkupParser(object):
183 if self.debug_level >= lev: 183 if self.debug_level >= lev:
184 for l in (fmt % argv).split('\n'): 184 for l in (fmt % argv).split('\n'):
185 print("[DEBUG] %s" % l) 185 print("[DEBUG] %s" % l)
186 186
187 inline_delims = [ "''", "'''", "[", "]", "[[", "]]", "{{", "}}", "|" ] 187 inline_delims = [ "''", "'''", "[", "]", "[[", "]]", "{{", "}}", "|" ]
188 188
189 token_class = { 189 token_class = {}
190 'NIL': WikiNode,
191 'NL': WikiNode,
192 'OTAG': WikiTagNode,
193 'CTAG': WikiTagNode,
194 'TAG': WikiTagNode,
195 'DELIM': WikiDelimNode,
196 'TEXT': WikiTextNode,
197 'PRE': WikiContentNode,
198 'PARA': WikiSeqNode,
199 'BAR': WikiNode,
200 'SEQ': WikiSeqNode,
201 'IND': WikiIndNode,
202 'REF': WikiRefNode,
203 'TMPL': WikiSeqNode,
204 'IT': WikiSeqNode,
205 'BOLD': WikiSeqNode,
206 'ELT': WikiEltNode,
207 'ENV': WikiEnvNode,
208 'LINK': WikiSeqNode,
209 'HDR': WikiHdrNode
210 }
211 190
212 def _new_node(self, **kwarg): 191 def _new_node(self, **kwarg):
213 return self.token_class[kwarg['type']](self, **kwarg) 192 return self.token_class[kwarg['type']](self, **kwarg)
214 193
215 def tokread(self): 194 def tokread(self):
216 """Read next token from the input. Return it as a subclass of WikiNode.""" 195 """Read next token from the input. Return it as a subclass of WikiNode."""
@@ -989,12 +968,35 @@ class WikiMarkup(WikiMarkupParser):
989 Base URL for images. Default is 968 Base URL for images. Default is
990 'http://upload.wikimedia.org/wikipedia/commons/thumb/a/bf' 969 'http://upload.wikimedia.org/wikipedia/commons/thumb/a/bf'
991 media_base=URL 970 media_base=URL
992 Base URL for media files. Default is 971 Base URL for media files. Default is
993 'http://www.mediawiki.org/xml/export-0.3' 972 'http://www.mediawiki.org/xml/export-0.3'
994 """ 973 """
974 self.token_class = {
975 'NIL': WikiNode,
976 'NL': WikiNode,
977 'OTAG': WikiTagNode,
978 'CTAG': WikiTagNode,
979 'TAG': WikiTagNode,
980 'DELIM': WikiDelimNode,
981 'TEXT': WikiTextNode,
982 'PRE': WikiContentNode,
983 'PARA': WikiSeqNode,
984 'BAR': WikiNode,
985 'SEQ': WikiSeqNode,
986 'IND': WikiIndNode,
987 'REF': WikiRefNode,
988 'TMPL': WikiSeqNode,
989 'IT': WikiSeqNode,
990 'BOLD': WikiSeqNode,
991 'ELT': WikiEltNode,
992 'ENV': WikiEnvNode,
993 'LINK': WikiSeqNode,
994 'HDR': WikiHdrNode
995 }
996
995 for kw in keywords: 997 for kw in keywords:
996 if kw == 'file': 998 if kw == 'file':
997 self.file = keywords[kw] 999 self.file = keywords[kw]
998 elif kw == 'filename': 1000 elif kw == 'filename':
999 self.file = open(keywords[kw]) 1001 self.file = open(keywords[kw])
1000 elif kw == 'text': 1002 elif kw == 'text':

Return to:

Send suggestions and report system problems to the System administrator.