File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 11###
22# Copyright (c) 2005, Jeremiah Fincher
33# Copyright (c) 2009, James McCoy
4- # Copyright (c) 2010-2021 , Valentin Lorentz
4+ # Copyright (c) 2010-2024 , Valentin Lorentz
55# All rights reserved.
66#
77# Redistribution and use in source and binary forms, with or without
@@ -59,24 +59,24 @@ class Title(utils.web.HtmlToText):
5959 entitydefs ['nbsp' ] = ' '
6060 def __init__ (self ):
6161 self .inTitle = False
62- self .inSvg = False
62+ self .inSvg = 0 # counter instead of boolean because svg can be nested
6363 utils .web .HtmlToText .__init__ (self )
6464
6565 @property
6666 def inHtmlTitle (self ):
67- return self .inTitle and not self .inSvg
67+ return self .inTitle and self .inSvg == 0
6868
6969 def handle_starttag (self , tag , attrs ):
7070 if tag == 'title' :
7171 self .inTitle = True
7272 elif tag == 'svg' :
73- self .inSvg = True
73+ self .inSvg += 1
7474
7575 def handle_endtag (self , tag ):
7676 if tag == 'title' :
7777 self .inTitle = False
7878 elif tag == 'svg' :
79- self .inSvg = False
79+ self .inSvg = max ( 0 , self . inSvg - 1 )
8080
8181 def append (self , data ):
8282 if self .inHtmlTitle :
You can’t perform that action at this time.
0 commit comments