import re from mistletoe.span_token import SpanToken class HalfwidthSpaces(SpanToken): """ Insert halfwidth space into span token (t. ex.) Identifies "t.ex." and "T.ex." with and without space in between. """ pattern = re.compile(r"\b(t|T)\.\s?(ex)\.") def __init__(self, match_object): self.first = match_object.group(1) self.second = match_object.group(2)