Kaydet (Commit) efe5ac40 authored tarafından Guido van Rossum's avatar Guido van Rossum

make reporting unbalanced tags an overridable method

üst b4728153
......@@ -226,8 +226,8 @@ class SGMLParser:
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 @@ class SGMLParser:
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:
......
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