mirror of
https://github.com/python/cpython.git
synced 2025-09-28 19:25:27 +00:00
added verbose option; added ismap/align/width/height to handle_image args
This commit is contained in:
parent
3c0bfd0dee
commit
453534a84d
1 changed files with 12 additions and 4 deletions
|
@ -14,8 +14,8 @@ from formatter import AS_IS
|
||||||
|
|
||||||
class HTMLParser(SGMLParser):
|
class HTMLParser(SGMLParser):
|
||||||
|
|
||||||
def __init__(self, formatter):
|
def __init__(self, formatter, verbose=0):
|
||||||
SGMLParser.__init__(self)
|
SGMLParser.__init__(self, verbose)
|
||||||
self.formatter = formatter
|
self.formatter = formatter
|
||||||
self.savedata = None
|
self.savedata = None
|
||||||
self.isindex = 0
|
self.isindex = 0
|
||||||
|
@ -66,7 +66,7 @@ class HTMLParser(SGMLParser):
|
||||||
|
|
||||||
# --- Hook for images; should probably be overridden
|
# --- Hook for images; should probably be overridden
|
||||||
|
|
||||||
def handle_image(self, src, alt):
|
def handle_image(self, src, alt, *args):
|
||||||
self.handle_data(alt)
|
self.handle_data(alt)
|
||||||
|
|
||||||
# --------- Top level elememts
|
# --------- Top level elememts
|
||||||
|
@ -348,6 +348,8 @@ class HTMLParser(SGMLParser):
|
||||||
alt = '(image)'
|
alt = '(image)'
|
||||||
ismap = ''
|
ismap = ''
|
||||||
src = ''
|
src = ''
|
||||||
|
width = 0
|
||||||
|
height = 0
|
||||||
for attrname, value in attrs:
|
for attrname, value in attrs:
|
||||||
if attrname == 'align':
|
if attrname == 'align':
|
||||||
align = value
|
align = value
|
||||||
|
@ -357,7 +359,13 @@ class HTMLParser(SGMLParser):
|
||||||
ismap = value
|
ismap = value
|
||||||
if attrname == 'src':
|
if attrname == 'src':
|
||||||
src = value
|
src = value
|
||||||
self.handle_image(src, alt)
|
if attrname == 'width':
|
||||||
|
try: width = string.atoi(value)
|
||||||
|
except: pass
|
||||||
|
if attrname == 'height':
|
||||||
|
try: height = string.atoi(value)
|
||||||
|
except: pass
|
||||||
|
self.handle_image(src, alt, ismap, align, width, height)
|
||||||
|
|
||||||
# --- Really Old Unofficial Deprecated Stuff
|
# --- Really Old Unofficial Deprecated Stuff
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue