mirror of
https://github.com/3b1b/manim.git
synced 2025-07-28 04:23:16 +08:00
Add StringMobject.get_specified_substrings
This commit is contained in:
@ -455,6 +455,14 @@ class StringMobject(SVGMobject, ABC):
|
||||
for span in self.labelled_spans[1:]
|
||||
]
|
||||
|
||||
def get_specified_substrings(self) -> list[str]:
|
||||
substrs = [
|
||||
self.string[slice(*span)]
|
||||
for span in self.labelled_spans[1:]
|
||||
]
|
||||
# Use dict.fromkeys to remove duplicates while retaining order
|
||||
return list(dict.fromkeys(substrs).keys())
|
||||
|
||||
def get_group_part_items(self) -> list[tuple[str, list[int]]]:
|
||||
if not self.labels:
|
||||
return []
|
||||
|
Reference in New Issue
Block a user