mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
clean up the API a little; exceptions are defined by this module
(needs documentation)
This commit is contained in:
parent
58ae830fd0
commit
583359ed2e
1 changed files with 13 additions and 5 deletions
|
|
@ -4,13 +4,18 @@ See the HTML 2.0 specification:
|
||||||
http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_toc.html
|
http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_toc.html
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sgmllib
|
||||||
|
|
||||||
from sgmllib import SGMLParser
|
|
||||||
from formatter import AS_IS
|
from formatter import AS_IS
|
||||||
|
|
||||||
__all__ = ["HTMLParser"]
|
__all__ = ["HTMLParser", "HTMLParseError"]
|
||||||
|
|
||||||
class HTMLParser(SGMLParser):
|
|
||||||
|
class HTMLParseError(sgmllib.SGMLParseError):
|
||||||
|
"""Error raised when an HTML document can't be parsed."""
|
||||||
|
|
||||||
|
|
||||||
|
class HTMLParser(sgmllib.SGMLParser):
|
||||||
"""This is the basic HTML parser class.
|
"""This is the basic HTML parser class.
|
||||||
|
|
||||||
It supports all entity names required by the XHTML 1.0 Recommendation.
|
It supports all entity names required by the XHTML 1.0 Recommendation.
|
||||||
|
|
@ -28,11 +33,14 @@ class HTMLParser(SGMLParser):
|
||||||
the parser.
|
the parser.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
SGMLParser.__init__(self, verbose)
|
sgmllib.SGMLParser.__init__(self, verbose)
|
||||||
self.formatter = formatter
|
self.formatter = formatter
|
||||||
|
|
||||||
|
def error(self, message):
|
||||||
|
raise HTMLParseError(message)
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
SGMLParser.reset(self)
|
sgmllib.SGMLParser.reset(self)
|
||||||
self.savedata = None
|
self.savedata = None
|
||||||
self.isindex = 0
|
self.isindex = 0
|
||||||
self.title = None
|
self.title = None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue