diff options
Diffstat (limited to 'wiki2html.py')
-rw-r--r-- | wiki2html.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/wiki2html.py b/wiki2html.py index 0330b92..05d4642 100644 --- a/wiki2html.py +++ b/wiki2html.py @@ -13,16 +13,18 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from wikimarkup import * -from types import TupleType from wikins import wiki_ns_re, wiki_ns import re -import urllib +try: + from urllib import quote as url_quote +except ImportError: + from urllib.parse import quote as url_quote class HtmlWikiMarkup (WikiMarkup): """ A (hopefully) general-purpose Wiki->HTML translator class. FIXME: 1. See WikiMarkup for a list 2. [[official position]]s : final 's' gets after closing </a> tag. @@ -45,13 +47,13 @@ class HtmlWikiMarkup (WikiMarkup): "defn": { "hdr": "dl", "elt": ["dt","dd"] } } def mktgt(self, tgt, lang = None): if not lang: lang = self.lang - return self.html_base % { 'lang' : lang } + urllib.quote(tgt) + return self.html_base % { 'lang' : lang } + url_quote(tgt) def tmpl_term(self, s): if len(s) == 2: return s[1] text = None trans = None @@ -81,13 +83,13 @@ class HtmlWikiMarkup (WikiMarkup): def fmtlink(self, elt, istmpl): arg = self.format(elt['content'][0]) text = None if len(elt['content']) > 1: - s = map(self.format, elt['content']) + s = [x for x in map(self.format, elt['content'])] if s[0] == 'disambigR' or s[0] == 'wikiquote': return "" elif len(s) > 1 and s[1] == 'thumb': return "" text = '<span class="template">' + s[1] + '</span>' if istmpl: |