|
|
@@ -1,6 +1,6 @@ |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
# |
|
|
|
# Copyright (C) 2012-2015 Ben Kurtovic <ben.kurtovic@gmail.com> |
|
|
|
# Copyright (C) 2012-2016 Ben Kurtovic <ben.kurtovic@gmail.com> |
|
|
|
# |
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy |
|
|
|
# of this software and associated documentation files (the "Software"), to deal |
|
|
@@ -264,14 +264,14 @@ class Tokenizer(object): |
|
|
|
elif self._context & contexts.TEMPLATE_PARAM_VALUE: |
|
|
|
self._context ^= contexts.TEMPLATE_PARAM_VALUE |
|
|
|
else: |
|
|
|
self._emit_all(self._pop(keep_context=True)) |
|
|
|
self._emit_all(self._pop()) |
|
|
|
self._context |= contexts.TEMPLATE_PARAM_KEY |
|
|
|
self._emit(tokens.TemplateParamSeparator()) |
|
|
|
self._push(self._context) |
|
|
|
|
|
|
|
def _handle_template_param_value(self): |
|
|
|
"""Handle a template parameter's value at the head of the string.""" |
|
|
|
self._emit_all(self._pop(keep_context=True)) |
|
|
|
self._emit_all(self._pop()) |
|
|
|
self._context ^= contexts.TEMPLATE_PARAM_KEY |
|
|
|
self._context |= contexts.TEMPLATE_PARAM_VALUE |
|
|
|
self._emit(tokens.TemplateParamEquals()) |
|
|
@@ -282,7 +282,7 @@ class Tokenizer(object): |
|
|
|
if not self._context & (contexts.HAS_TEXT | contexts.HAS_TEMPLATE): |
|
|
|
self._fail_route() |
|
|
|
elif self._context & contexts.TEMPLATE_PARAM_KEY: |
|
|
|
self._emit_all(self._pop(keep_context=True)) |
|
|
|
self._emit_all(self._pop()) |
|
|
|
self._head += 1 |
|
|
|
return self._pop() |
|
|
|
|
|
|
@@ -1074,14 +1074,14 @@ class Tokenizer(object): |
|
|
|
|
|
|
|
def _parse_table(self): |
|
|
|
"""Parse a wikicode table by starting with the first line.""" |
|
|
|
reset = self._head + 1 |
|
|
|
reset = self._head |
|
|
|
self._head += 2 |
|
|
|
self._push(contexts.TABLE_OPEN) |
|
|
|
try: |
|
|
|
padding = self._handle_table_style("\n") |
|
|
|
except BadRoute: |
|
|
|
self._head = reset |
|
|
|
self._emit_text("{|") |
|
|
|
self._emit_text("{") |
|
|
|
return |
|
|
|
style = self._pop() |
|
|
|
|
|
|
@@ -1090,7 +1090,7 @@ class Tokenizer(object): |
|
|
|
table = self._parse(contexts.TABLE_OPEN) |
|
|
|
except BadRoute: |
|
|
|
self._head = reset |
|
|
|
self._emit_text("{|") |
|
|
|
self._emit_text("{") |
|
|
|
return |
|
|
|
|
|
|
|
self._emit_table_tag("{|", "table", style, padding, None, table, "|}") |
|
|
@@ -1338,9 +1338,10 @@ class Tokenizer(object): |
|
|
|
if result is not None: |
|
|
|
return result |
|
|
|
elif self._read(-1) in ("\n", self.START) and this in ("#", "*", ";", ":"): |
|
|
|
self._handle_list() |
|
|
|
elif self._read(-1) in ("\n", self.START) and this == next == self._read(2) == self._read(3) == "-": |
|
|
|
self._handle_hr() |
|
|
|
self._handle_list() |
|
|
|
elif self._read(-1) in ("\n", self.START) and ( |
|
|
|
this == next == self._read(2) == self._read(3) == "-"): |
|
|
|
self._handle_hr() |
|
|
|
elif this in ("\n", ":") and self._context & contexts.DL_TERM: |
|
|
|
self._handle_dl_term() |
|
|
|
if this == "\n": |
|
|
@@ -1352,7 +1353,7 @@ class Tokenizer(object): |
|
|
|
if self._can_recurse(): |
|
|
|
self._parse_table() |
|
|
|
else: |
|
|
|
self._emit_text("{|") |
|
|
|
self._emit_text("{") |
|
|
|
elif self._context & contexts.TABLE_OPEN: |
|
|
|
if this == next == "|" and self._context & contexts.TABLE_TD_LINE: |
|
|
|
if self._context & contexts.TABLE_CELL_OPEN: |
|
|
|