]> git.llucax.com Git - software/subdivxget.git/commitdiff
Ignore br tags for tag depth calculations
authorLeandro Lucarella <luca@llucax.com.ar>
Sat, 14 Jul 2012 18:09:51 +0000 (20:09 +0200)
committerLeandro Lucarella <luca@llucax.com.ar>
Sat, 14 Jul 2012 18:12:54 +0000 (20:12 +0200)
SubDivX uses old, unclosed br tags, so they break the tag depth
calculation.

subdivxget

index 395eb35bfdf08b47480bc02364a61d9a79d5fa75..d7c32d1f61047a2a8ea3c7703bb87a74bf0f3b4a 100755 (executable)
@@ -67,7 +67,8 @@ class SubDivXHTMLParser(HTMLParser.HTMLParser):
                                self.attr = 'titulo'
                        elif attrs.get('href', '').startswith(self.down_uri):
                                self.cur['url'] = attrs['href']
-               if self.parsing:
+               # br are usually not closed, so ignore them in depth calculation
+               if self.parsing and tag != 'br':
                        self.depth += 1
 
        def handle_endtag(self, tag):
@@ -75,7 +76,9 @@ class SubDivXHTMLParser(HTMLParser.HTMLParser):
                        if tag == 'script' or tag == 'style':
                                self.in_script_style = False
                                return
-                       self.depth -= 1
+                       # see comment in handle_starttag()
+                       if tag != 'br':
+                               self.depth -= 1
                if self.depth == 0:
                        self.parsing = False