summaryrefslogtreecommitdiffabout
path: root/wiki2text.py
authorSergey Poznyakoff <gray@gnu.org.ua>2009-03-05 22:13:37 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2009-03-05 22:13:37 (GMT)
commit6b699b060de765112fa03435b4afbd258262d1fb (patch) (side-by-side diff)
tree940b584e5618a73215bc0a269f0c0a4ac718a74f /wiki2text.py
parenta8cd24f0f5cbefccdefd2a4a5166b89c6c8f7a54 (diff)
downloadwikitrans-6b699b060de765112fa03435b4afbd258262d1fb.tar.gz
wikitrans-6b699b060de765112fa03435b4afbd258262d1fb.tar.bz2
Lots of formatting kludges
Diffstat (limited to 'wiki2text.py') (more/less context) (ignore whitespace changes)
-rw-r--r--wiki2text.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/wiki2text.py b/wiki2text.py
index 09bd86a..5fcd718 100644
--- a/wiki2text.py
+++ b/wiki2text.py
@@ -20,2 +20,3 @@ from types import TupleType
from wikins import wiki_ns_re, wiki_ns
+import re
import urllib
@@ -69,5 +70,13 @@ class TextWikiMarkup (WikiMarkup):
if len(elt[1]) > 1:
- text = self.format(elt[1][1])
+ s = map(self.format, elt[1])
+ text = s[1]
else:
+ s = None
text = None
+
+ if s:
+ if s[0] == 'disambigR':
+ return ""
+ if len(s) > 1 and s[1] == 'thumb':
+ return ""
(qual,sep,tgt) = arg.partition(':')
@@ -145,3 +154,3 @@ class TextWikiMarkup (WikiMarkup):
string += " "
- string += s.rstrip(" ")
+ string += s
else:
@@ -158,3 +167,3 @@ class TextWikiMarkup (WikiMarkup):
if s:
- string += " " + s.rstrip(" ")
+ string += " " + s
string = "_" + string.lstrip(" ") + "_"
@@ -169,3 +178,3 @@ class TextWikiMarkup (WikiMarkup):
string += " "
- string += s.rstrip(" ")
+ string += s
string = string.upper()
@@ -174,3 +183,7 @@ class TextWikiMarkup (WikiMarkup):
elif elt[0] == TMPL:
- string = '[' + self.fmtlink(elt, True) + ']'
+ s = self.fmtlink(elt, True)
+ if s:
+ string = '[' + s + ']'
+ else:
+ string = s
elif elt[0] == BAR:
@@ -198,5 +211,5 @@ class TextWikiMarkup (WikiMarkup):
if type == ENVUNNUM:
- string += self.indent(lev, "- " + x.lstrip(" "))
+ string += self.fmtpara(self.indent(lev, "- " + x.lstrip(" ")))
elif type == ENVNUM:
- string += self.indent(lev, "%d. %s" % (n, x))
+ string += self.fmtpara(self.indent(lev, "%d. %s" % (n, x)))
n += 1

Return to:

Send suggestions and report system problems to the System administrator.