aboutsummaryrefslogtreecommitdiff
path: root/wiki2text.py
diff options
context:
space:
mode:
Diffstat (limited to 'wiki2text.py')
-rw-r--r--wiki2text.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/wiki2text.py b/wiki2text.py
index c94ae51..3084ee4 100644
--- a/wiki2text.py
+++ b/wiki2text.py
@@ -142,6 +142,26 @@ class TextWikiMarkup (WikiMarkup):
length += wsc + wlen
return output + linebuf
+ supported_tags = [ 'nowiki', 'code' ]
+ def input_tag(self, tag):
+ return tag['tag'] in self.supported_tags
+
+ def str_tag(self, elt):
+ if elt['tag'] == 'nowiki':
+ return elt['content']
+ elif elt['tag'] == 'code':
+ kwdict = {
+ 'nested': self.nested + 1,
+ 'lang': self.lang,
+ 'text': elt['content'],
+ 'html_base': self.html_base,
+ 'image_base': self.image_base,
+ 'media_base': self.media_base }
+ markup = TextWiktionaryMarkup(**kwdict)
+ markup.debug_level = self.debug_level
+ markup.parse()
+ return str(markup)
+
def format(self, elt):
if elt['type'] == 'TEXT':
if isinstance(elt['content'],list):
@@ -155,11 +175,18 @@ class TextWikiMarkup (WikiMarkup):
string += s
else:
string = elt['content']
+ elif elt['type'] == 'PRE':
+ string = ""
+ for x in elt['content']:
+ string += self.format(x)
+ string += '\n'
elif elt['type'] == 'PARA':
string = "";
for x in elt['content']:
string += self.format(x)
string = self.fmtpara(string) + '\n\n'
+ elif elt['type'] == 'TAG':
+ string = self.str_tag(elt)
elif elt['type'] == 'IT':
string = ""
for x in elt['content']:
@@ -214,7 +241,7 @@ class TextWikiMarkup (WikiMarkup):
string += self.fmtpara(self.indent(lev, "%d. %s" % (n, x)))
n += 1
elif type == "defn":
- if s[1] == 0:
+ if s['subtype'] == 0:
string += self.indent(lev-1, x)
else:
string += self.indent(lev+3, x)

Return to:

Send suggestions and report system problems to the System administrator.