瀏覽代碼

Fix handling of self-closing tags (closes #31)

tags/v0.3
Ben Kurtovic 11 年之前
父節點
當前提交
61fc5b5eab
共有 3 個文件被更改,包括 7 次插入6 次删除
  1. +3
    -2
      mwparserfromhell/nodes/tag.py
  2. +2
    -2
      mwparserfromhell/parser/builder.py
  3. +2
    -2
      mwparserfromhell/parser/tokenizer.py

+ 3
- 2
mwparserfromhell/nodes/tag.py 查看文件

@@ -79,8 +79,9 @@ class Tag(TagDefinitions, Node):
if attr.value:
for child in getter(attr.value):
yield attr.value, child
for child in getter(self.contents):
yield self.contents, child
if self.contents:
for child in getter(self.contents):
yield self.contents, child

def __strip__(self, normalize, collapse):
if self.type in self.TAGS_VISIBLE:


+ 2
- 2
mwparserfromhell/parser/builder.py 查看文件

@@ -191,8 +191,8 @@ class Builder(object):
self._push()
elif isinstance(token, tokens.TagAttrQuote):
quoted = True
elif isinstance(token, (tokens.TagAttrStart,
tokens.TagCloseOpen)):
elif isinstance(token, (tokens.TagAttrStart, tokens.TagCloseOpen,
tokens.TagCloseSelfclose)):
self._tokens.append(token)
if name is not None:
return Attribute(name, self._pop(), quoted, padding)


+ 2
- 2
mwparserfromhell/parser/tokenizer.py 查看文件

@@ -26,8 +26,8 @@ import re

from . import contexts
from . import tokens
from ..nodes.tag import Tag
from ..compat import htmlentities
from ..nodes.tag import Tag

__all__ = ["Tokenizer"]

@@ -431,7 +431,7 @@ class Tokenizer(object):
try:
return Tag.TRANSLATIONS[text]
except KeyError:
self._fail_route()
return Tag.TAG_UNKNOWN

def _actually_close_tag_opening(self):
"""Handle cleanup at the end of a opening tag.


Loading…
取消
儲存