From 461500637e07ac0b6266a85a18b30f3d13810e1d Mon Sep 17 00:00:00 2001 From: YishiMichael Date: Thu, 31 Mar 2022 10:57:25 +0800 Subject: [PATCH] Fix type bug --- manimlib/mobject/svg/labelled_string.py | 10 +++++----- manimlib/mobject/svg/text_mobject.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manimlib/mobject/svg/labelled_string.py b/manimlib/mobject/svg/labelled_string.py index a0d66c4d..989f2cb9 100644 --- a/manimlib/mobject/svg/labelled_string.py +++ b/manimlib/mobject/svg/labelled_string.py @@ -187,8 +187,9 @@ class LabelledString(_StringSVG): inserted_string_pairs: list[tuple[Span, tuple[str, str]]], other_repl_items: list[tuple[Span, str]] ) -> dict[Span, str]: + result = dict(other_repl_items) if not inserted_string_pairs: - return other_repl_items.copy() + return result indices, _, _, inserted_strings = zip(*sorted([ ( @@ -200,12 +201,11 @@ class LabelledString(_StringSVG): for span, str_pair in inserted_string_pairs for flag in range(2) ])) - result = { + result.update({ (index, index): "".join(inserted_strings[slice(*item_span)]) for index, item_span in LabelledString.compress_neighbours(indices) - } - result.update(other_repl_items) + }) return result @staticmethod @@ -272,7 +272,7 @@ class LabelledString(_StringSVG): return (0, len(self.string)) def get_space_spans(self) -> list[Span]: - return self.find_spans(r"\s+") + return self.find_spans(r"\s") # Parsing diff --git a/manimlib/mobject/svg/text_mobject.py b/manimlib/mobject/svg/text_mobject.py index 83637b01..2b6211d8 100644 --- a/manimlib/mobject/svg/text_mobject.py +++ b/manimlib/mobject/svg/text_mobject.py @@ -470,7 +470,7 @@ class MarkupText(LabelledString): def get_label_span_list(self) -> list[Span]: breakup_indices = remove_list_redundancies(list(it.chain(*it.chain( - self.space_spans, + self.find_spans(r"\s+"), self.find_spans(r"\b"), self.specified_spans ))))