]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
make reporting unbalanced tags an overridable method
authorGuido van Rossum <guido@python.org>
Thu, 22 Jun 1995 18:56:36 +0000 (18:56 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 22 Jun 1995 18:56:36 +0000 (18:56 +0000)
Lib/sgmllib.py

index 17e5745f0ba4115a06f22a5357df81d2e0ae7259..2c92c3180f533bcab743582289ef0a51b84089c9 100644 (file)
@@ -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: