Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 453534a

Browse files
committed
added verbose option; added ismap/align/width/height to handle_image args
1 parent 3c0bfd0 commit 453534a

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

Lib/htmllib.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
class HTMLParser(SGMLParser):
1616

17-
def __init__(self, formatter):
18-
SGMLParser.__init__(self)
17+
def __init__(self, formatter, verbose=0):
18+
SGMLParser.__init__(self, verbose)
1919
self.formatter = formatter
2020
self.savedata = None
2121
self.isindex = 0
@@ -66,7 +66,7 @@ def anchor_end(self):
6666

6767
# --- Hook for images; should probably be overridden
6868

69-
def handle_image(self, src, alt):
69+
def handle_image(self, src, alt, *args):
7070
self.handle_data(alt)
7171

7272
# --------- Top level elememts
@@ -348,6 +348,8 @@ def do_img(self, attrs):
348348
alt = '(image)'
349349
ismap = ''
350350
src = ''
351+
width = 0
352+
height = 0
351353
for attrname, value in attrs:
352354
if attrname == 'align':
353355
align = value
@@ -357,7 +359,13 @@ def do_img(self, attrs):
357359
ismap = value
358360
if attrname == 'src':
359361
src = value
360-
self.handle_image(src, alt)
362+
if attrname == 'width':
363+
try: width = string.atoi(value)
364+
except: pass
365+
if attrname == 'height':
366+
try: height = string.atoi(value)
367+
except: pass
368+
self.handle_image(src, alt, ismap, align, width, height)
361369

362370
# --- Really Old Unofficial Deprecated Stuff
363371

0 commit comments

Comments
 (0)