Move block outside try/except as it doesnt need to be in there

This commit is contained in:
Kovid Goyal 2022-06-06 08:17:15 +05:30
parent 4ed6364b61
commit 98f6e24106
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -330,15 +330,14 @@ def mark(pattern: str, post_processors: Iterable[PostprocessorFunc], text: str,
try:
for func in post_processors:
s, e = func(text, s, e)
except InvalidMatch:
continue
groupdict = match_object.groupdict()
for group_name in groupdict:
group_idx = pat.groupindex[group_name]
gs, ge = match_object.span(group_idx)
gs, ge = max(gs, s), min(ge, e)
groupdict[group_name] = sanitize_pat.sub('', text[gs:ge])
except InvalidMatch:
continue
mark_text = sanitize_pat.sub('', text[s:e])
yield Mark(idx, s, e, mark_text, groupdict)