make reporting unbalanced tags an overridable method

This commit is contained in:
Guido van Rossum 1995-06-22 18:56:36 +00:00
parent b47281539a
commit efe5ac404f
1 changed files with 7 additions and 2 deletions

View File

@ -226,8 +226,8 @@ def parse_endtag(self, data):
if self.stack and self.stack[-1] == tag:
del self.stack[-1]
else:
print '*** Unbalanced </' + tag + '>'
print '*** Stack:', self.stack
self.report_unbalanced(tag)
# Now repair it
found = None
for i in range(len(self.stack)):
if self.stack[i] == tag: found = i
@ -235,6 +235,11 @@ def parse_endtag(self, data):
del self.stack[found:]
method()
# Example -- report an unbalanced </...> tag.
def report_unbalanced(self, tag):
print '*** Unbalanced </' + tag + '>'
print '*** Stack:', self.stack
# Example -- handle character reference, no need to override
def handle_charref(self, name):
try: