Commit 42be3b5f authored by Guido van Rossum's avatar Guido van Rossum

Properly fix the problem that Evan was trying to fix in his previous

checkin to this file.  For <br>, we now end up calling
emitEndElement() with isend = 1 and implied = -1, so it doesn't emit
</br> text, but properly pops the todo stack.
parent 8bc611ee
...@@ -191,15 +191,14 @@ class HTMLTALParser(HTMLParser): ...@@ -191,15 +191,14 @@ class HTMLTALParser(HTMLParser):
# Overriding HTMLParser methods # Overriding HTMLParser methods
def handle_starttag(self, tag, attrs): def handle_starttag(self, tag, attrs):
if tag in EMPTY_HTML_TAGS:
return self.handle_startendtag(tag, attrs)
self.close_para_tags(tag) self.close_para_tags(tag)
self.tagstack.append(tag) self.tagstack.append(tag)
self.scan_xmlns(attrs) self.scan_xmlns(attrs)
attrlist, taldict, metaldict = self.extract_attrs(attrs) attrlist, taldict, metaldict = self.extract_attrs(attrs)
self.gen.emitStartElement(tag, attrlist, taldict, metaldict, self.gen.emitStartElement(tag, attrlist, taldict, metaldict,
self.getpos()) self.getpos())
if tag in EMPTY_HTML_TAGS:
self.implied_endtag(tag, -1)
def handle_startendtag(self, tag, attrs): def handle_startendtag(self, tag, attrs):
self.close_para_tags(tag) self.close_para_tags(tag)
...@@ -257,16 +256,16 @@ class HTMLTALParser(HTMLParser): ...@@ -257,16 +256,16 @@ class HTMLTALParser(HTMLParser):
def implied_endtag(self, tag, implied): def implied_endtag(self, tag, implied):
assert tag == self.tagstack[-1] assert tag == self.tagstack[-1]
assert implied in (-1, 1, 2) assert implied in (-1, 1, 2)
if implied > 0: isend = (implied < 0)
if tag in TIGHTEN_IMPLICIT_CLOSE_TAGS: if tag in TIGHTEN_IMPLICIT_CLOSE_TAGS:
# Pick out trailing whitespace from the program, and # Pick out trailing whitespace from the program, and
# insert the close tag before the whitespace. # insert the close tag before the whitespace.
white = self.gen.unEmitWhitespace() white = self.gen.unEmitWhitespace()
self.gen.emitEndElement(tag, implied=implied) else:
if white: white = None
self.gen.emitRawText(white) self.gen.emitEndElement(tag, isend=isend, implied=implied)
else: if white:
self.gen.emitEndElement(tag, implied=implied) self.gen.emitRawText(white)
self.tagstack.pop() self.tagstack.pop()
self.pop_xmlns() self.pop_xmlns()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment