summaryrefslogtreecommitdiff
path: root/wikitrans/wiki2texi.py
diff options
context:
space:
mode:
Diffstat (limited to 'wikitrans/wiki2texi.py')
-rw-r--r--wikitrans/wiki2texi.py82
1 files changed, 44 insertions, 38 deletions
diff --git a/wikitrans/wiki2texi.py b/wikitrans/wiki2texi.py
index 55dffe2..936a133 100644
--- a/wikitrans/wiki2texi.py
+++ b/wikitrans/wiki2texi.py
@@ -3,3 +3,3 @@
# Copyright (C) 2015-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
@@ -32,12 +32,13 @@ import urllib
+
class Acc(list):
- def prepend(self,x):
- self.insert(0,x)
-
+ def prepend(self, x):
+ self.insert(0, x)
+
def is_empty(self):
return len(self) == 0
-
+
def clear(self):
self = []
-
+
def tail(self, n = 1):
@@ -67,3 +68,3 @@ class Acc(list):
n -= l
-
+
def trimnl(self):
@@ -71,3 +72,3 @@ class Acc(list):
self.trim(1)
-
+
def trimpara(self):
@@ -75,9 +76,9 @@ class Acc(list):
self.trim(2)
-
+
def endswith(self, x):
return self.tail(len(x)) == x
-
+
def in_new_para(self):
return self.is_empty() or self.endswith('\n\n')
-
+
def __str__(self):
@@ -85,2 +86,3 @@ class Acc(list):
+
class TexiTextNode(WikiTextNode):
@@ -88,3 +90,3 @@ class TexiTextNode(WikiTextNode):
parser = self.parser
- if isinstance(self.content,list):
+ if isinstance(self.content, list):
for s in self.content:
@@ -94,2 +96,3 @@ class TexiTextNode(WikiTextNode):
+
class TexiTagNode(WikiTagNode):
@@ -127,5 +130,6 @@ class TexiTagNode(WikiTagNode):
parser._print('</' + self.tag + '>')
-
+
+
class TexiParaNode(WikiSeqNode):
- def format(self):
+ def format(self):
parser = self.parser
@@ -137,3 +141,4 @@ class TexiParaNode(WikiSeqNode):
parser._print('\n', nl=True)
-
+
+
class TexiPreNode(WikiSeqNode):
@@ -148,2 +153,3 @@ class TexiPreNode(WikiSeqNode):
+
class TexiFontNode(WikiSeqNode):
@@ -158,2 +164,3 @@ class TexiFontNode(WikiSeqNode):
+
class TexiHdrNode(WikiHdrNode):
@@ -176,2 +183,3 @@ class TexiHdrNode(WikiHdrNode):
+
class TexiBarNode(WikiNode):
@@ -180,2 +188,3 @@ class TexiBarNode(WikiNode):
+
class TexiIndNode(WikiIndNode):
@@ -187,2 +196,3 @@ class TexiIndNode(WikiIndNode):
+
class TexiEnvNode(WikiEnvNode):
@@ -218,3 +228,4 @@ class TexiEnvNode(WikiEnvNode):
parser._print('@end table\n', nl=True, escape=False)
-
+
+
class TexiLinkNode(WikiSeqNode):
@@ -244,3 +255,3 @@ class TexiLinkNode(WikiSeqNode):
- (qual,sep,tgt) = arg.partition(':')
+ (qual, sep, tgt) = arg.partition(':')
if text:
@@ -250,2 +261,3 @@ class TexiLinkNode(WikiSeqNode):
+
class TexiRefNode(WikiRefNode):
@@ -261,6 +273,7 @@ class TexiRefNode(WikiRefNode):
parser._print("@uref{%s}" % target, escape=False)
-
+
+
class TexiWikiMarkup(WikiMarkup):
"""Wiki markup to Texinfo translator class.
-
+
Usage:
@@ -272,5 +285,5 @@ class TexiWikiMarkup(WikiMarkup):
print(str(x))
-
+
"""
-
+
nested = 0
@@ -279,5 +292,5 @@ class TexiWikiMarkup(WikiMarkup):
'@top',
- '@chapter',
- '@section',
- '@subsection',
+ '@chapter',
+ '@section',
+ '@subsection',
'@subsubsection'
@@ -319,3 +332,3 @@ class TexiWikiMarkup(WikiMarkup):
the WikiMarkup class.
-
+
Additional arguments:
@@ -344,5 +357,5 @@ class TexiWikiMarkup(WikiMarkup):
"""
-
+
super(TexiWikiMarkup, self).__init__(*args, **keywords)
-
+
self.token_class['TEXT'] = TexiTextNode
@@ -359,3 +372,3 @@ class TexiWikiMarkup(WikiMarkup):
self.token_class['REF'] = TexiRefNode
-
+
if "sectioning_model" in keywords:
@@ -396,3 +409,3 @@ class TexiWikiMarkup(WikiMarkup):
return str(s)
-
+
def __str__(self):
@@ -403,8 +416 @@ class TexiWikiMarkup(WikiMarkup):
return self._end_print()
-
-
-
-
-
-
-

Return to:

Send suggestions and report system problems to the System administrator.