summaryrefslogtreecommitdiff
path: root/wikitrans/wiki2text.py
diff options
context:
space:
mode:
Diffstat (limited to 'wikitrans/wiki2text.py')
-rw-r--r--wikitrans/wiki2text.py66
1 files changed, 39 insertions, 27 deletions
diff --git a/wikitrans/wiki2text.py b/wikitrans/wiki2text.py
index 88e7610..7585bff 100644
--- a/wikitrans/wiki2text.py
+++ b/wikitrans/wiki2text.py
@@ -3,3 +3,3 @@
# Copyright (C) 2008-2018 Sergey Poznyakoff
-#
+#
# This program is free software; you can redistribute it and/or modify
@@ -8,3 +8,3 @@
# any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
@@ -13,3 +13,3 @@
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
@@ -37,2 +37,3 @@ except ImportError:
+
class TextSeqNode(WikiSeqNode):
@@ -45,6 +46,7 @@ class TextSeqNode(WikiSeqNode):
return string
-
+
+
class TextTextNode(WikiTextNode):
def format(self):
- if isinstance(self.content,list):
+ if isinstance(self.content, list):
string = ""
@@ -61,2 +63,3 @@ class TextTextNode(WikiTextNode):
+
class TextPreNode(WikiSeqNode):
@@ -69,2 +72,3 @@ class TextPreNode(WikiSeqNode):
+
class TextParaNode(WikiSeqNode):
@@ -77,2 +81,3 @@ class TextParaNode(WikiSeqNode):
+
class TextItNode(WikiSeqNode):
@@ -85,3 +90,4 @@ class TextItNode(WikiSeqNode):
return "_" + string.lstrip(" ") + "_"
-
+
+
class TextBoldNode(WikiSeqNode):
@@ -97,2 +103,3 @@ class TextBoldNode(WikiSeqNode):
+
class TextLinkNode(WikiSeqNode):
@@ -112,3 +119,3 @@ class TextLinkNode(WikiSeqNode):
return ""
- (qual,sep,tgt) = arg.partition(':')
+ (qual, sep, tgt) = arg.partition(':')
if tgt != '':
@@ -140,3 +147,4 @@ class TextLinkNode(WikiSeqNode):
return text
-
+
+
class TextTmplNode(TextLinkNode):
@@ -144,3 +152,4 @@ class TextTmplNode(TextLinkNode):
return '[' + super(TextTmplNode, self).format() + ']'
-
+
+
class TextBarNode(WikiNode):
@@ -152,2 +161,3 @@ class TextBarNode(WikiNode):
+
class TextHdrNode(WikiHdrNode):
@@ -159,3 +169,4 @@ class TextHdrNode(WikiHdrNode):
+ "\n\n")
-
+
+
class TextRefNode(WikiRefNode):
@@ -168,2 +179,3 @@ class TextRefNode(WikiRefNode):
+
class TextEnvNode(WikiEnvNode):
@@ -190,8 +202,7 @@ class TextEnvNode(WikiEnvNode):
string += self.parser.indent(lev+3, x)
-
if not string.endswith("\n"):
string += "\n"
-
return string
+
class TextIndNode(WikiIndNode):
@@ -200,2 +211,3 @@ class TextIndNode(WikiIndNode):
+
class TextTagNode(WikiTagNode):
@@ -217,4 +229,4 @@ class TextTagNode(WikiTagNode):
s += '>' + self.content.format() + '</' + self.tag + '>'
- return s
-
+ return s
+
@@ -230,3 +242,3 @@ class TextWikiMarkup(WikiMarkup):
print(str(x))
-
+
"""
@@ -245,3 +257,3 @@ class TextWikiMarkup(WikiMarkup):
references = []
-
+
def __init__(self, *args, **keywords):
@@ -256,5 +268,5 @@ class TextWikiMarkup(WikiMarkup):
Class-specific arguments:
-
+
width=N
- Limit output width to N columns. Default is 78.
+ Limit output width to N columns. Default is 78.
show_urls=False
@@ -264,4 +276,4 @@ class TextWikiMarkup(WikiMarkup):
"""
-
- super(TextWikiMarkup,self).__init__(*args, **keywords)
+
+ super(TextWikiMarkup, self).__init__(*args, **keywords)
if 'width' in keywords:
@@ -285,3 +297,3 @@ class TextWikiMarkup(WikiMarkup):
self.token_class['TAG'] = TextTagNode
-
+
def wiki_ns_name(self, str):
@@ -294,3 +306,3 @@ class TextWikiMarkup(WikiMarkup):
return None
-
+
def mktgt(self, tgt, lang = None):
@@ -299,6 +311,6 @@ class TextWikiMarkup(WikiMarkup):
return self.html_base % { 'lang' : lang } + url_quote(tgt)
-
+
def indent(self, lev, text):
if text.find('\n') == -1:
- s = (" " * lev) + text
+ s = (" " * lev) + text
else:
@@ -311,3 +323,3 @@ class TextWikiMarkup(WikiMarkup):
return s
-
+
def fmtpara(self, input):
@@ -333,3 +345,3 @@ class TextWikiMarkup(WikiMarkup):
return output + linebuf
-
+
def __str__(self):
@@ -340,2 +352,3 @@ class TextWikiMarkup(WikiMarkup):
+
class TextWiktionaryMarkup(TextWikiMarkup):
@@ -347,2 +360 @@ class TextWiktionaryMarkup(TextWikiMarkup):
html_base='http://%(lang)s.wiktionary.org/wiki/'
-

Return to:

Send suggestions and report system problems to the System administrator.