summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--wikitrans/wikimarkup.py48
1 files changed, 25 insertions, 23 deletions
diff --git a/wikitrans/wikimarkup.py b/wikitrans/wikimarkup.py
index d199335..0ce0e15 100644
--- a/wikitrans/wikimarkup.py
+++ b/wikitrans/wikimarkup.py
@@ -183,35 +183,14 @@ class WikiMarkupParser(object):
if self.debug_level >= lev:
for l in (fmt % argv).split('\n'):
print("[DEBUG] %s" % l)
inline_delims = [ "''", "'''", "[", "]", "[[", "]]", "{{", "}}", "|" ]
- token_class = {
- 'NIL': WikiNode,
- 'NL': WikiNode,
- 'OTAG': WikiTagNode,
- 'CTAG': WikiTagNode,
- 'TAG': WikiTagNode,
- 'DELIM': WikiDelimNode,
- 'TEXT': WikiTextNode,
- 'PRE': WikiContentNode,
- 'PARA': WikiSeqNode,
- 'BAR': WikiNode,
- 'SEQ': WikiSeqNode,
- 'IND': WikiIndNode,
- 'REF': WikiRefNode,
- 'TMPL': WikiSeqNode,
- 'IT': WikiSeqNode,
- 'BOLD': WikiSeqNode,
- 'ELT': WikiEltNode,
- 'ENV': WikiEnvNode,
- 'LINK': WikiSeqNode,
- 'HDR': WikiHdrNode
- }
-
+ token_class = {}
+
def _new_node(self, **kwarg):
return self.token_class[kwarg['type']](self, **kwarg)
def tokread(self):
"""Read next token from the input. Return it as a subclass of WikiNode."""
line = None
@@ -989,12 +968,35 @@ class WikiMarkup(WikiMarkupParser):
Base URL for images. Default is
'http://upload.wikimedia.org/wikipedia/commons/thumb/a/bf'
media_base=URL
Base URL for media files. Default is
'http://www.mediawiki.org/xml/export-0.3'
"""
+ self.token_class = {
+ 'NIL': WikiNode,
+ 'NL': WikiNode,
+ 'OTAG': WikiTagNode,
+ 'CTAG': WikiTagNode,
+ 'TAG': WikiTagNode,
+ 'DELIM': WikiDelimNode,
+ 'TEXT': WikiTextNode,
+ 'PRE': WikiContentNode,
+ 'PARA': WikiSeqNode,
+ 'BAR': WikiNode,
+ 'SEQ': WikiSeqNode,
+ 'IND': WikiIndNode,
+ 'REF': WikiRefNode,
+ 'TMPL': WikiSeqNode,
+ 'IT': WikiSeqNode,
+ 'BOLD': WikiSeqNode,
+ 'ELT': WikiEltNode,
+ 'ENV': WikiEnvNode,
+ 'LINK': WikiSeqNode,
+ 'HDR': WikiHdrNode
+ }
+
for kw in keywords:
if kw == 'file':
self.file = keywords[kw]
elif kw == 'filename':
self.file = open(keywords[kw])
elif kw == 'text':

Return to:

Send suggestions and report system problems to the System administrator.