Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion manim/mobject/text/tex_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,11 @@ def _locate_first_match(
first_match_length = 0
first_match = None
for substring in substrings_to_isolate:
match = re.match(f"(.*?)({re.escape(substring)})(.*)", unprocessed_string)
match = re.match(
f"(.*?)({re.escape(substring)})(.*)",
unprocessed_string,
flags=re.DOTALL,
)
if match and len(match.group(1)) < first_match_start:
first_match = match
first_match_start = len(match.group(1))
Expand Down
7 changes: 7 additions & 0 deletions tests/module/mobject/text/test_texmobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,10 @@ def test_tex_garbage_collection(tmpdir, monkeypatch, config):

tex_with_log = Tex("Hello World, again!") # 45b4e7819cc20cb1.tex
assert Path("media", "Tex", "45b4e7819cc20cb1.log").exists()


def test_locate_first_match_multiline_substring(config) -> None:
unprocessed = "This is a very long string,\n which tests the implementation."
match = MathTex("a")._locate_first_match(["implementation"], unprocessed)
assert match is not None
assert match.group(2) == "implementation"
Loading