aboutsummaryrefslogtreecommitdiff
path: root/wiki2text.py
diff options
context:
space:
mode:
Diffstat (limited to 'wiki2text.py')
-rw-r--r--wiki2text.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/wiki2text.py b/wiki2text.py
index 916391e..5041ea0 100644
--- a/wiki2text.py
+++ b/wiki2text.py
@@ -15,10 +15,14 @@
15# You should have received a copy of the GNU General Public License 15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>. 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18from wikimarkup import * 18from wit.wikimarkup import *
19from wikins import wiki_ns_re, wiki_ns 19from wit.wikins import wiki_ns_re, wiki_ns
20import re 20import re
21import urllib 21try:
22 from urllib import quote as url_quote
23except ImportError:
24 from urllib.parse import quote as url_quote
25
22 26
23class TextWikiMarkup (WikiMarkup): 27class TextWikiMarkup (WikiMarkup):
24 """ 28 """
@@ -58,11 +62,11 @@ class TextWikiMarkup (WikiMarkup):
58 if str.beginswith(elt[0]) and str.endswith(elt[1]): 62 if str.beginswith(elt[0]) and str.endswith(elt[1]):
59 return elt[2] 63 return elt[2]
60 return None 64 return None
61 65
62 def mktgt(self, tgt, lang = None): 66 def mktgt(self, tgt, lang = None):
63 if not lang: 67 if not lang:
64 lang = self.lang 68 lang = self.lang
65 return self.html_base % { 'lang' : lang } + urllib.quote(tgt) 69 return self.html_base % { 'lang' : lang } + url_quote(tgt)
66 70
67 def fmtlink(self, elt, istmpl): 71 def fmtlink(self, elt, istmpl):
68 arg = self.format(elt['content'][0]) 72 arg = self.format(elt['content'][0])
@@ -87,8 +91,8 @@ class TextWikiMarkup (WikiMarkup):
87 return "" 91 return ""
88 text = "[%s: %s]" % (qual, text if text else arg) 92 text = "[%s: %s]" % (qual, text if text else arg)
89 tgt = self.image_base + '/' + \ 93 tgt = self.image_base + '/' + \
90 urllib.quote(tgt) + \ 94 url_quote(tgt) + \
91 '/250px-' + urllib.quote(tgt) 95 '/250px-' + url_quote(tgt)
92 elif ns == 'NS_MEDIA': 96 elif ns == 'NS_MEDIA':
93 text = "[%s]" % (qual) 97 text = "[%s]" % (qual)
94 else: 98 else:
@@ -112,7 +116,7 @@ class TextWikiMarkup (WikiMarkup):
112 s = (" " * lev) + text 116 s = (" " * lev) + text
113 else: 117 else:
114 s = "" 118 s = ""
115 for elt in text.split('\n'): 119 for elt in text.decode("utf-8").split('\n'):
116 if elt: 120 if elt:
117 s += (" " * lev) + elt + '\n' 121 s += (" " * lev) + elt + '\n'
118 if not text.endswith('\n'): 122 if not text.endswith('\n'):

Return to:

Send suggestions and report system problems to the System administrator.