Support passing in complete environment tags

This commit is contained in:
YishiMichael 2022-04-13 22:51:55 +08:00
parent bff9f74b04
commit 0c1e5b337b
No known key found for this signature in database
GPG key ID: EC615C0C5A86BC80
2 changed files with 8 additions and 5 deletions

View file

@ -373,6 +373,8 @@ class LabelledString(_StringSVG, ABC):
return []
def check_overlapping(self) -> None:
if len(self.label_span_list) >= 16777216:
raise ValueError("Cannot label that many substrings")
for span_0, span_1 in it.product(self.label_span_list, repeat=2):
if not span_0[0] < span_1[0] < span_0[1] < span_1[1]:
continue

View file

@ -266,11 +266,12 @@ class MTex(LabelledString):
result = self.get_replaced_substr(self.full_span, span_repl_dict)
if self.tex_environment:
result = "\n".join([
f"\\begin{{{self.tex_environment}}}",
result,
f"\\end{{{self.tex_environment}}}"
])
if isinstance(self.tex_environment, str):
prefix = f"\\begin{{{self.tex_environment}}}"
suffix = f"\\end{{{self.tex_environment}}}"
else:
prefix, suffix = self.tex_environment
result = "\n".join([prefix, result, suffix])
if self.alignment:
result = "\n".join([self.alignment, result])
if use_plain_file: