summaryrefslogtreecommitdiff
path: root/wiki2text.py
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-03-03 17:08:17 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-03-03 17:08:17 +0200
commitb667a722ceb7db64ed243de706aba795d2a895e9 (patch)
tree75efb9a939584ae2a87c9b2f31c22b199f538686 /wiki2text.py
parent6b0bfa216f6512e929dbe63e6c9b9cb6934dc3c5 (diff)
downloadwikitrans-b667a722ceb7db64ed243de706aba795d2a895e9.tar.gz
wikitrans-b667a722ceb7db64ed243de706aba795d2a895e9.tar.bz2
Merge fmtelt with format
Diffstat (limited to 'wiki2text.py')
-rw-r--r--wiki2text.py34
1 files changed, 5 insertions, 29 deletions
diff --git a/wiki2text.py b/wiki2text.py
index 5ed91fa..09bd86a 100644
--- a/wiki2text.py
+++ b/wiki2text.py
@@ -133,7 +133,7 @@ class TextWikiMarkup (WikiMarkup):
length += wsc + wlen
return output + linebuf
- def fmtelt(self, elt, indent=0):
+ def format(self, elt):
if elt[0] == TEXT:
if isinstance(elt[1],list):
string = ""
@@ -204,19 +204,14 @@ class TextWikiMarkup (WikiMarkup):
string += "\n"
elif elt[0] == IND:
string = (" " * elt[1]) + self.format(elt[2]) + '\n'
- else:
- string = str(elt)
- return string
-
- def format(self, elt, indent=0):
- if elt[0] == SEQ:
+ elif elt[0] == SEQ:
string = ""
for x in elt[1]:
if len(string) > 1 and not string[-1].isspace():
string += ' '
- string += self.format(x, indent)
+ string += self.format(x)
else:
- string = self.fmtelt(elt, indent)
+ string = str(elt)
return string
def __str__(self):
@@ -229,24 +224,5 @@ class TextWiktionaryMarkup (TextWikiMarkup):
"""
See documentation for HtmlWiktionaryMarkup
"""
+ # FIXME: It is supposed to do something about templates
- seq_pos = 0
-
- def str_seq(self, tok, env):
- s = ""
- self.seq_pos=0
- for t in tok[1:]:
- x = self.fmtok(t, env)
- if x:
- s += x
- self.seq_pos += 1
- return s
-
- def str_tmpl(self, tok, env):
- arg = self.fmtok(tok[1], env)
- if arg and arg != '':
- if self.seq_pos > 0:
- return arg
- else:
- return "\n" + arg + ":\n"
-

Return to:

Send suggestions and report system problems to the System administrator.