mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Add StringMobject.get_specified_substrings
This commit is contained in:
parent
6044e475a4
commit
49d4472e7e
1 changed files with 8 additions and 0 deletions
|
@ -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 []
|
||||
|
|
Loading…
Add table
Reference in a new issue