summaryrefslogtreecommitdiff
path: root/wikimarkup.py
diff options
context:
space:
mode:
Diffstat (limited to 'wikimarkup.py')
-rw-r--r--wikimarkup.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/wikimarkup.py b/wikimarkup.py
index 4eb4ed0..fa60c80 100644
--- a/wikimarkup.py
+++ b/wikimarkup.py
@@ -511,11 +511,16 @@ class WikiMarkup (BaseWikiMarkup):
return None
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:
- return True
+ 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
return False
def is_empty_text(self, elt):
@@ -526,9 +531,14 @@ class WikiMarkup (BaseWikiMarkup):
return False
elif re.search('\w', elt[1]):
return False
- else:
- return True
+ return True
return False
+
+ 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):
BaseWikiMarkup.parse(self)
@@ -539,9 +549,9 @@ class WikiMarkup (BaseWikiMarkup):
break
# Remove trailing links
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.