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 @@ | |||
13 | # GNU General Public License for more details. | 13 | # GNU General Public License for more details. |
14 | # | 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 | ||
18 | from wikimarkup import * | 18 | from wikimarkup import * |
19 | from types import TupleType | ||
20 | from wikins import wiki_ns_re, wiki_ns | 19 | from wikins import wiki_ns_re, wiki_ns |
21 | import re | 20 | import re |
22 | import urllib | 21 | try: |
22 | from urllib import quote as url_quote | ||
23 | except ImportError: | ||
24 | from urllib.parse import quote as url_quote | ||
23 | 25 | ||
24 | class HtmlWikiMarkup (WikiMarkup): | 26 | class HtmlWikiMarkup (WikiMarkup): |
25 | """ | 27 | """ |
26 | A (hopefully) general-purpose Wiki->HTML translator class. | 28 | A (hopefully) general-purpose Wiki->HTML translator class. |
27 | FIXME: 1. See WikiMarkup for a list | 29 | FIXME: 1. See WikiMarkup for a list |
28 | 2. [[official position]]s : final 's' gets after closing </a> tag. | 30 | 2. [[official position]]s : final 's' gets after closing </a> tag. |
@@ -45,13 +47,13 @@ class HtmlWikiMarkup (WikiMarkup): | |||
45 | "defn": { "hdr": "dl", | 47 | "defn": { "hdr": "dl", |
46 | "elt": ["dt","dd"] } } | 48 | "elt": ["dt","dd"] } } |
47 | 49 | ||
48 | def mktgt(self, tgt, lang = None): | 50 | def mktgt(self, tgt, lang = None): |
49 | if not lang: | 51 | if not lang: |
50 | lang = self.lang | 52 | lang = self.lang |
51 | return self.html_base % { 'lang' : lang } + urllib.quote(tgt) | 53 | return self.html_base % { 'lang' : lang } + url_quote(tgt) |
52 | 54 | ||
53 | def tmpl_term(self, s): | 55 | def tmpl_term(self, s): |
54 | if len(s) == 2: | 56 | if len(s) == 2: |
55 | return s[1] | 57 | return s[1] |
56 | text = None | 58 | text = None |
57 | trans = None | 59 | trans = None |
@@ -81,13 +83,13 @@ class HtmlWikiMarkup (WikiMarkup): | |||
81 | 83 | ||
82 | 84 | ||
83 | def fmtlink(self, elt, istmpl): | 85 | def fmtlink(self, elt, istmpl): |
84 | arg = self.format(elt['content'][0]) | 86 | arg = self.format(elt['content'][0]) |
85 | text = None | 87 | text = None |
86 | if len(elt['content']) > 1: | 88 | if len(elt['content']) > 1: |
87 | s = map(self.format, elt['content']) | 89 | s = [x for x in map(self.format, elt['content'])] |
88 | if s[0] == 'disambigR' or s[0] == 'wikiquote': | 90 | if s[0] == 'disambigR' or s[0] == 'wikiquote': |
89 | return "" | 91 | return "" |
90 | elif len(s) > 1 and s[1] == 'thumb': | 92 | elif len(s) > 1 and s[1] == 'thumb': |
91 | return "" | 93 | return "" |
92 | text = '<span class="template">' + s[1] + '</span>' | 94 | text = '<span class="template">' + s[1] + '</span>' |
93 | if istmpl: | 95 | if istmpl: |