def apply_func_to_html_text(match, func=icu_upper, handle_entities=handle_entities):
 f = (lambda text: handle_entities(text, func))
 parts = re.split(u'(<[^>]+>)', match.group())
 parts = ((x if x.startswith(u'<') else f(x)) for x in parts)
 return u''.join(parts)

def apply_func_to_html_text ( match , func = icu_upper , handle_entities = handle_entities ) : f = ( lambda text : handle_entities ( text , func ) ) parts = re . split ( u'(<[^>]+>)' , match . group ( ) ) parts = ( ( x if x . startswith ( u'<' ) else f ( x ) ) for x in parts ) return u'' . join ( parts )
apply the specified function only to text between html tag definitions .