diff --git a/mwparserfromhell/parser/builder.py b/mwparserfromhell/parser/builder.py index 9d046a6..929c269 100644 --- a/mwparserfromhell/parser/builder.py +++ b/mwparserfromhell/parser/builder.py @@ -76,8 +76,8 @@ class Builder(object): if isinstance(token, tokens.TemplateParamSeparator): if not params: name = self._pop() - default = self._wrap(unicode(min(int_key_range - int_keys))) - param = self._handle_parameter(default) + default = unicode(min(int_key_range - int_keys)) + param = self._handle_parameter(self._wrap([Text(default)])) if re.match(r"[1-9][0-9]*$", param.name.strip()): # We try a more restrictive test for integers than # try: int(), because "01" as a key will pass through int() diff --git a/mwparserfromhell/parser/tokenizer.py b/mwparserfromhell/parser/tokenizer.py index 2f16d15..5befcf0 100644 --- a/mwparserfromhell/parser/tokenizer.py +++ b/mwparserfromhell/parser/tokenizer.py @@ -107,9 +107,9 @@ class Tokenizer(object): if self._context & contexts.TEMPLATE_NAME and self._stack: head = self._stack[-1] if isinstance(head, tokens.Text): - text, this = head.text, self._read() - if text.strip() and text.endswith("\n") and this != "\n": - raise BadRoute(self._pop()) + if head.text.strip() and head.text.endswith("\n"): + if self._read() not in ["|", "=", "\n"]: + raise BadRoute(self._pop()) def _parse_template(self): reset = self._head