MCPcopy Create free account
hub / github.com/Sigil-Ebook/Sigil / apply_func_to_html_text

Function apply_func_to_html_text

src/Resource_Files/python3lib/functionrep.py:40–46  ·  view source on GitHub ↗

Apply the specified function only to text between HTML tag definitions.

(match, func=toUpper, handle_entities=handle_entities)

Source from the content-addressed store, hash-verified

38 return f(match.group())
39
40def 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)

Calls 2

fFunction · 0.85
groupMethod · 0.80

Tested by

no test coverage detected