Apply the specified function only to text between HTML tag definitions.
(match, func=toUpper, handle_entities=handle_entities)
| 38 | return f(match.group()) |
| 39 | |
| 40 | def apply_func_to_html_text(match, func=toUpper, handle_entities=handle_entities): |
| 41 | ''' Apply the specified function only to text between HTML tag definitions. ''' |
| 42 | def f(text): |
| 43 | return handle_entities(text, func) |
| 44 | parts = re.split(r'(<[^>]+>)', match.group()) |
| 45 | parts = (x if x.startswith('<') else f(x) for x in parts) |
| 46 | return ''.join(parts) |
| 47 | |
| 48 | |
| 49 | # ('Upper-case text', upper, apply_func_to_match_groups) |
no test coverage detected