summaryrefslogtreecommitdiff
path: root/wikimarkup.py
diff options
context:
space:
mode:
Diffstat (limited to 'wikimarkup.py')
-rw-r--r--wikimarkup.py31
1 files changed, 21 insertions, 10 deletions
diff --git a/wikimarkup.py b/wikimarkup.py
index 9a79d1e..0c6d2f2 100644
--- a/wikimarkup.py
+++ b/wikimarkup.py
@@ -181,20 +181,29 @@ class BaseWikiMarkup(object):
if m:
if (pos < m.start(0)):
yield({'type': 'TEXT', 'content': line[pos:m.start(0)]})
pos = m.end(0)
if m and line[m.start(0)] != '<':
- if m.group(0)[0] in envtypes and pos < len(line) and line[pos] == ":":
- yield({ 'type': 'DELIM',
- 'content': m.group(0),
- 'continuation': True })
+ content = m.group(0)
+ if content[0] in envtypes:
+ t = { 'type': 'DELIM',
+ 'content': content,
+ 'continuation': pos < len(line) and line[pos] == ":" }
+ if t['continuation']:
+ t['content'] += t['content'][0]
+ pos += 1
+
+ yield(t)
+
+ while pos < len(line) and line[pos] in [' ', '\t']:
pos += 1
else:
yield({ 'type': 'DELIM',
- 'content': m.group(0) })
+ 'content': content,
+ 'continuation': False})
else:
if m:
pos -= 1
t = None
m = otag.match(line, pos)
if m and m.group('tag') in self.tags:
@@ -302,14 +311,14 @@ class BaseWikiMarkup(object):
# Push the token on stack
stack.append(i)
# Redefine all non-matched tokens as TEXT
for i in stack:
self.toklist[i]['type'] = 'TEXT'
- def peektkn(self):
- return self.toklist[self.tokind]
+ def peektkn(self, off=0):
+ return self.toklist[self.tokind-off]
def setkn(self,val):
self.toklist[self.tokind] = val
def getkn(self):
self.newline = self.tokind == 0 or self.toklist[self.tokind-1]['type'] == 'NL'
@@ -601,13 +610,13 @@ class BaseWikiMarkup(object):
break
elif len(tok['content']) > lev:
self.ungetkn()
elt = self.parse_env(type, len(tok['content']))
else:
elt = self.parse_line()
- if 'continuation' not in tok:
+ if not tok['continuation']:
list.append({ 'type': 'ELT',
'subtype': envtypes[tok['content'][0]][1],
'content': elt })
continue
if list:
@@ -678,16 +687,18 @@ class BaseWikiMarkup(object):
return { 'type': 'BAR' }
elif tok['content'][0:2] == "==":
return self.parse_header(tok['content'])
elif tok['content'][0] in envtypes:
type = envtypes[tok['content'][0]][0]
lev = len(tok['content'])
+ if tok['content'][0] == ':':
+ t = self.peektkn(2)
+ if not (t['type'] == 'DELIM' and t['content'] == ';'):
+ return self.parse_indent(lev)
self.ungetkn()
return self.parse_env(type, lev)
- elif tok['content'][0] == ":":
- return self.parse_indent(len(tok['content']))
else:
self.ungetkn()
return self.parse_para()
elif toktype == 'NL':
return { 'type': 'TEXT', 'content': '\n' }
elif toktype == 'OTAG':

Return to:

Send suggestions and report system problems to the System administrator.