summaryrefslogtreecommitdiff
path: root/wikitrans/wiki2html.py
diff options
context:
space:
mode:
Diffstat (limited to 'wikitrans/wiki2html.py')
-rw-r--r--wikitrans/wiki2html.py53
1 files changed, 33 insertions, 20 deletions
diff --git a/wikitrans/wiki2html.py b/wikitrans/wiki2html.py
index fc6b142..0696dce 100644
--- a/wikitrans/wiki2html.py
+++ b/wikitrans/wiki2html.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
@@ -42,5 +42,6 @@ except ImportError:
from cgi import escape as html_escape
-
+
__all__ = [ "HtmlWikiMarkup", "HtmlWiktionaryMarkup" ]
+
class HtmlSeqNode(WikiSeqNode):
@@ -51,3 +52,4 @@ class HtmlSeqNode(WikiSeqNode):
return s
-
+
+
class HtmlLinkNode(HtmlSeqNode):
@@ -72,4 +74,4 @@ class HtmlLinkNode(HtmlSeqNode):
return text
-
- (qual,sep,tgt) = arg.partition(':')
+
+ (qual, sep, tgt) = arg.partition(':')
if tgt != '':
@@ -94,2 +96,3 @@ class HtmlLinkNode(HtmlSeqNode):
+
class HtmlRefNode(WikiRefNode):
@@ -103,2 +106,3 @@ class HtmlRefNode(WikiRefNode):
+
class HtmlFontNode(HtmlSeqNode):
@@ -113,5 +117,6 @@ class HtmlFontNode(HtmlSeqNode):
+
class HtmlTextNode(HtmlSeqNode):
def format(self):
- if isinstance(self.content,list):
+ if isinstance(self.content, list):
s = ''.join(self.content)
@@ -121,2 +126,3 @@ class HtmlTextNode(HtmlSeqNode):
+
class HtmlHdrNode(WikiHdrNode):
@@ -128,2 +134,3 @@ class HtmlHdrNode(WikiHdrNode):
+
class HtmlBarNode(WikiNode):
@@ -132,2 +139,3 @@ class HtmlBarNode(WikiNode):
+
class HtmlEnvNode(WikiEnvNode):
@@ -148,3 +156,4 @@ class HtmlEnvNode(WikiEnvNode):
return string
-
+
+
class HtmlTagNode(WikiTagNode):
@@ -158,3 +167,3 @@ class HtmlTagNode(WikiTagNode):
n = self.idx+1
- return '<sup id="cite_ref-%d" class="reference"><a name="cite_ref-%d" href=#cite_note-%d">%d</a></sup>' % (n,n,n,n)
+ return '<sup id="cite_ref-%d" class="reference"><a name="cite_ref-%d" href=#cite_note-%d">%d</a></sup>' % (n, n, n, n)
elif self.tag == 'references':
@@ -164,3 +173,3 @@ class HtmlTagNode(WikiTagNode):
for ref in self.parser.references:
- n += 1
+ n += 1
s += ('<li id="cite_note-%d">'
@@ -172,3 +181,3 @@ class HtmlTagNode(WikiTagNode):
+ '</span>'
- + '</li>\n') % (n,n)
+ + '</li>\n') % (n, n)
s += '</ol>\n</div>\n'
@@ -182,3 +191,4 @@ class HtmlTagNode(WikiTagNode):
return s + '</' + self.tag + '>'
-
+
+
class HtmlParaNode(HtmlSeqNode):
@@ -187,2 +197,3 @@ class HtmlParaNode(HtmlSeqNode):
+
class HtmlPreNode(HtmlSeqNode):
@@ -195,2 +206,3 @@ class HtmlPreNode(HtmlSeqNode):
+
class HtmlIndNode(WikiIndNode):
@@ -198,3 +210,3 @@ class HtmlIndNode(WikiIndNode):
return ("<dl><dd>" * self.level) + self.content.format() + "</dd></dl>" * self.level
-
+
@@ -225,5 +237,5 @@ class HtmlWikiMarkup(WikiMarkup):
The arguments have the same meaning as in the WikiMarkup constructor.
-
+
"""
-
+
super(HtmlWikiMarkup, self).__init__(*args, **kwargs)
@@ -251,4 +263,4 @@ class HtmlWikiMarkup(WikiMarkup):
return elt[2]
- return None
-
+ return None
+
envt = { "unnumbered": { "hdr": "ul",
@@ -258,3 +270,3 @@ class HtmlWikiMarkup(WikiMarkup):
"defn": { "hdr": "dl",
- "elt": ["dt","dd"] } }
+ "elt": ["dt","dd"] } }
@@ -293,3 +305,3 @@ class HtmlWikiMarkup(WikiMarkup):
return text
-
+
def __str__(self):
@@ -300,2 +312,3 @@ class HtmlWikiMarkup(WikiMarkup):
+
class HtmlWiktionaryMarkup(HtmlWikiMarkup):

Return to:

Send suggestions and report system problems to the System administrator.