|
@@ -1067,24 +1067,21 @@ class Tokenizer(object): |
|
|
self._head += len(markup) |
|
|
self._head += len(markup) |
|
|
style = None |
|
|
style = None |
|
|
try: |
|
|
try: |
|
|
(cell_context, cell) = self._parse(table_context | contexts.TABLE_CELL_STYLE_POSSIBLE) |
|
|
|
|
|
|
|
|
cell_context, cell, reset_for_style = self._parse(table_context | contexts.TABLE_CELL_STYLE_POSSIBLE) |
|
|
except BadRoute: |
|
|
except BadRoute: |
|
|
self._head = reset |
|
|
self._head = reset |
|
|
raise |
|
|
raise |
|
|
# except for handling cell style |
|
|
|
|
|
except StopIteration: |
|
|
|
|
|
self._pop() |
|
|
|
|
|
|
|
|
if reset_for_style: |
|
|
self._head = reset + len(markup) |
|
|
self._head = reset + len(markup) |
|
|
try: |
|
|
try: |
|
|
self._push(table_context) |
|
|
self._push(table_context) |
|
|
(style, padding) = self._parse_as_table_style("|") |
|
|
(style, padding) = self._parse_as_table_style("|") |
|
|
# Don't parse the style separator |
|
|
# Don't parse the style separator |
|
|
self._head += 1 |
|
|
self._head += 1 |
|
|
(cell_context, cell) = self._parse(table_context) |
|
|
|
|
|
|
|
|
cell_context, cell, reset_for_style = self._parse(table_context) |
|
|
except BadRoute: |
|
|
except BadRoute: |
|
|
self._head = reset |
|
|
self._head = reset |
|
|
raise |
|
|
raise |
|
|
|
|
|
|
|
|
self._emit(tokens.TagOpenOpen(wiki_markup=markup)) |
|
|
self._emit(tokens.TagOpenOpen(wiki_markup=markup)) |
|
|
self._emit_text(tag) |
|
|
self._emit_text(tag) |
|
|
if style: |
|
|
if style: |
|
@@ -1132,13 +1129,10 @@ class Tokenizer(object): |
|
|
self._handle_tag_data(data, this) |
|
|
self._handle_tag_data(data, this) |
|
|
self._head += 1 |
|
|
self._head += 1 |
|
|
|
|
|
|
|
|
def _handle_table_cell_end(self): |
|
|
|
|
|
"""Returns the context and stack in a tuple.""" |
|
|
|
|
|
return (self._context, self._pop()) |
|
|
|
|
|
|
|
|
|
|
|
def _handle_cell_style(self): |
|
|
|
|
|
"""Pop the cell off the stack and try to parse as style.""" |
|
|
|
|
|
raise StopIteration() |
|
|
|
|
|
|
|
|
def _handle_table_cell_end(self, reset_for_style=False): |
|
|
|
|
|
"""Returns the context, stack, and whether to reset the cell for style |
|
|
|
|
|
in a tuple.""" |
|
|
|
|
|
return self._context, self._pop(), reset_for_style |
|
|
|
|
|
|
|
|
def _verify_safe(self, this): |
|
|
def _verify_safe(self, this): |
|
|
"""Make sure we are not trying to write an invalid character.""" |
|
|
"""Make sure we are not trying to write an invalid character.""" |
|
@@ -1316,7 +1310,7 @@ class Tokenizer(object): |
|
|
return self._handle_table_cell_end() |
|
|
return self._handle_table_cell_end() |
|
|
self._handle_table_cell("!!", "th", contexts.TABLE_TH_LINE) |
|
|
self._handle_table_cell("!!", "th", contexts.TABLE_TH_LINE) |
|
|
elif this == "|" and self._context & contexts.TABLE_CELL_STYLE_POSSIBLE: |
|
|
elif this == "|" and self._context & contexts.TABLE_CELL_STYLE_POSSIBLE: |
|
|
self._handle_cell_style() |
|
|
|
|
|
|
|
|
return self._handle_table_cell_end(reset_for_style=True) |
|
|
# on newline, clear out cell line contexts |
|
|
# on newline, clear out cell line contexts |
|
|
elif this == "\n" and self._context & contexts.TABLE_CELL_LINE_CONTEXTS: |
|
|
elif this == "\n" and self._context & contexts.TABLE_CELL_LINE_CONTEXTS: |
|
|
self._context &= ~contexts.TABLE_CELL_LINE_CONTEXTS |
|
|
self._context &= ~contexts.TABLE_CELL_LINE_CONTEXTS |
|
|