real_token = word_token
ix = text.find(real_token, ix)
end = ix + len(real_token)
spans.append((ix, end))
ix = end
return spans
After Change
// treated as starting quotes).
if (""" in text) or ("""" in text):
// Find double quotes and converted quotes
matched = [m.group()for m in re.finditer(r"``|"{2}|\"", text)]
// Replace converted quotes back to double quotes
tokens = [matched.pop(0) if tok in [""", "``", """"] else tok for tok in raw_tokens]