diff options
Diffstat (limited to 'wikimarkup.py')
-rw-r--r-- | wikimarkup.py | 33 |
1 files changed, 22 insertions, 11 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): | |||
181 | if m: | 181 | if m: |
182 | if (pos < m.start(0)): | 182 | if (pos < m.start(0)): |
183 | yield({'type': 'TEXT', 'content': line[pos:m.start(0)]}) | 183 | yield({'type': 'TEXT', 'content': line[pos:m.start(0)]}) |
184 | pos = m.end(0) | 184 | pos = m.end(0) |
185 | 185 | ||
186 | if m and line[m.start(0)] != '<': | 186 | if m and line[m.start(0)] != '<': |
187 | if m.group(0)[0] in envtypes and pos < len(line) and line[pos] == ":": | 187 | content = m.group(0) |
188 | yield({ 'type': 'DELIM', | 188 | if content[0] in envtypes: |
189 | 'content': m.group(0), | 189 | t = { 'type': 'DELIM', |
190 | 'continuation': True }) | 190 | 'content': content, |
191 | pos += 1 | 191 | 'continuation': pos < len(line) and line[pos] == ":" } |
192 | if t['continuation']: | ||
193 | t['content'] += t['content'][0] | ||
194 | pos += 1 | ||
195 | |||
196 | yield(t) | ||
197 | |||
198 | while pos < len(line) and line[pos] in [' ', '\t']: | ||
199 | pos += 1 | ||
192 | else: | 200 | else: |
193 | yield({ 'type': 'DELIM', | 201 | yield({ 'type': 'DELIM', |
194 | 'content': m.group(0) }) | 202 | 'content': content, |
203 | 'continuation': False}) | ||
195 | else: | 204 | else: |
196 | if m: | 205 | if m: |
197 | pos -= 1 | 206 | pos -= 1 |
198 | t = None | 207 | t = None |
199 | m = otag.match(line, pos) | 208 | m = otag.match(line, pos) |
200 | if m and m.group('tag') in self.tags: | 209 | if m and m.group('tag') in self.tags: |
@@ -302,14 +311,14 @@ class BaseWikiMarkup(object): | |||
302 | # Push the token on stack | 311 | # Push the token on stack |
303 | stack.append(i) | 312 | stack.append(i) |
304 | # Redefine all non-matched tokens as TEXT | 313 | # Redefine all non-matched tokens as TEXT |
305 | for i in stack: | 314 | for i in stack: |
306 | self.toklist[i]['type'] = 'TEXT' | 315 | self.toklist[i]['type'] = 'TEXT' |
307 | 316 | ||
308 | def peektkn(self): | 317 | def peektkn(self, off=0): |
309 | return self.toklist[self.tokind] | 318 | return self.toklist[self.tokind-off] |
310 | 319 | ||
311 | def setkn(self,val): | 320 | def setkn(self,val): |
312 | self.toklist[self.tokind] = val | 321 | self.toklist[self.tokind] = val |
313 | 322 | ||
314 | def getkn(self): | 323 | def getkn(self): |
315 | self.newline = self.tokind == 0 or self.toklist[self.tokind-1]['type'] == 'NL' | 324 | self.newline = self.tokind == 0 or self.toklist[self.tokind-1]['type'] == 'NL' |
@@ -601,13 +610,13 @@ class BaseWikiMarkup(object): | |||
601 | break | 610 | break |
602 | elif len(tok['content']) > lev: | 611 | elif len(tok['content']) > lev: |
603 | self.ungetkn() | 612 | self.ungetkn() |
604 | elt = self.parse_env(type, len(tok['content'])) | 613 | elt = self.parse_env(type, len(tok['content'])) |
605 | else: | 614 | else: |
606 | elt = self.parse_line() | 615 | elt = self.parse_line() |
607 | if 'continuation' not in tok: | 616 | if not tok['continuation']: |
608 | list.append({ 'type': 'ELT', | 617 | list.append({ 'type': 'ELT', |
609 | 'subtype': envtypes[tok['content'][0]][1], | 618 | 'subtype': envtypes[tok['content'][0]][1], |
610 | 'content': elt }) | 619 | 'content': elt }) |
611 | continue | 620 | continue |
612 | 621 | ||
613 | if list: | 622 | if list: |
@@ -678,16 +687,18 @@ class BaseWikiMarkup(object): | |||
678 | return { 'type': 'BAR' } | 687 | return { 'type': 'BAR' } |
679 | elif tok['content'][0:2] == "==": | 688 | elif tok['content'][0:2] == "==": |
680 | return self.parse_header(tok['content']) | 689 | return self.parse_header(tok['content']) |
681 | elif tok['content'][0] in envtypes: | 690 | elif tok['content'][0] in envtypes: |
682 | type = envtypes[tok['content'][0]][0] | 691 | type = envtypes[tok['content'][0]][0] |
683 | lev = len(tok['content']) | 692 | lev = len(tok['content']) |
693 | if tok['content'][0] == ':': | ||
694 | t = self.peektkn(2) | ||
695 | if not (t['type'] == 'DELIM' and t['content'] == ';'): | ||
696 | return self.parse_indent(lev) | ||
684 | self.ungetkn() | 697 | self.ungetkn() |
685 | return self.parse_env(type, lev) | 698 | return self.parse_env(type, lev) |
686 | elif tok['content'][0] == ":": | ||
687 | return self.parse_indent(len(tok['content'])) | ||
688 | else: | 699 | else: |
689 | self.ungetkn() | 700 | self.ungetkn() |
690 | return self.parse_para() | 701 | return self.parse_para() |
691 | elif toktype == 'NL': | 702 | elif toktype == 'NL': |
692 | return { 'type': 'TEXT', 'content': '\n' } | 703 | return { 'type': 'TEXT', 'content': '\n' } |
693 | elif toktype == 'OTAG': | 704 | elif toktype == 'OTAG': |