summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-03-08 00:30:59 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-03-08 00:30:59 +0200
commita8d15328a95bc16c3d9f4ca06c0c69767899f678 (patch)
tree9ec0df4e03725853c07cc5016979b74ef9707485
parentec326ad225c6cda0051f1c7b3751639f4823d4ac (diff)
downloadwikitrans-a8d15328a95bc16c3d9f4ca06c0c69767899f678.tar.gz
wikitrans-a8d15328a95bc16c3d9f4ca06c0c69767899f678.tar.bz2
Another buch of dirty kludges
-rw-r--r--wiki2html.py2
-rw-r--r--wiki2text.py2
-rw-r--r--wikimarkup.py26
3 files changed, 20 insertions, 10 deletions
diff --git a/wiki2html.py b/wiki2html.py
index 62c6da0..81ada65 100644
--- a/wiki2html.py
+++ b/wiki2html.py
@@ -84,3 +84,3 @@ class HtmlWikiMarkup (WikiMarkup):
s = map(self.format, elt[1])
- if s[0] == 'disambigR':
+ if s[0] == 'disambigR' or s[0] == 'wikiquote':
return ""
diff --git a/wiki2text.py b/wiki2text.py
index 5fcd718..0f8dd5f 100644
--- a/wiki2text.py
+++ b/wiki2text.py
@@ -77,3 +77,3 @@ class TextWikiMarkup (WikiMarkup):
if s:
- if s[0] == 'disambigR':
+ if s[0] == 'disambigR' or s[0] == 'wikiquote':
return ""
diff --git a/wikimarkup.py b/wikimarkup.py
index 4eb4ed0..fa60c80 100644
--- a/wikimarkup.py
+++ b/wikimarkup.py
@@ -513,6 +513,11 @@ class WikiMarkup (BaseWikiMarkup):
def is_lang_link(self, elt):
- if elt[0] == LINK and isinstance(elt[1],list) and len(elt[1]) == 1 \
- and elt[1][0][0] == TEXT:
- m = re.match('(.+):', elt[1][0][1])
- if m and m.group(1) in self.langtab:
+ if elt[0] == LINK and isinstance(elt[1],list) and len(elt[1]) == 1:
+ if elt[1][0][0] == TEXT:
+ m = re.match('([\w-]+):', elt[1][0][1])
+ if m: # and m.group(1) in self.langtab:
+ return True
+ elif elt[1][0][0] == SEQ and len(elt[1][0][1]) == 1 and\
+ elt[1][0][1][0][0] == TEXT:
+ m = re.match('([\w-]+):',elt[1][0][1][0][1])
+ if m: # and m.group(1) in self.langtab:
return True
@@ -528,3 +533,2 @@ class WikiMarkup (BaseWikiMarkup):
return False
- else:
return True
@@ -532,2 +536,8 @@ class WikiMarkup (BaseWikiMarkup):
+ def is_empty_para(self, seq):
+ for x in seq:
+ if not (self.is_lang_link(x) or self.is_empty_text(x)):
+ return False
+ return True
+
def parse(self):
@@ -541,5 +551,5 @@ class WikiMarkup (BaseWikiMarkup):
for i in range(len(self.tree)-1, 0, -1):
- if not (self.is_lang_link(self.tree[i]) \
- or self.is_empty_text(self.tree[i])):
- self.tree = self.tree[0:i]
+ if self.tree[i][0] == PARA \
+ and not self.is_empty_para(self.tree[i][1]):
+ self.tree = self.tree[0:i+1]
break

Return to:

Send suggestions and report system problems to the System administrator.