Refactor LabelledString

This commit is contained in:
YishiMichael 2022-04-15 23:30:42 +08:00
parent 14dfd776dc
commit dbefc3b256
No known key found for this signature in database
GPG key ID: EC615C0C5A86BC80

View file

@ -135,17 +135,17 @@ class MTex(LabelledString):
if span_begin in brace_indices_dict.keys():
span_end = brace_indices_dict[span_begin] + 1
else:
span = self.find_spans(script_pattern, pos=span_begin)[0]
if span[0] != span_begin:
spans = self.find_spans(script_pattern, pos=span_begin)
if not spans or spans[0][0] != span_begin:
script_name = {
"_": "subscript",
"^": "superscript"
}[script_char]
}[self.get_string(char_span)]
raise ValueError(
f"Unclear {script_name} detected while parsing. "
"Please use braces to clarify"
)
span_end = span[1]
span_end = spans[0][1]
result.append((span_begin, span_end))
return result