File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -184,7 +184,7 @@ def _texcode_for_environment(environment: str) -> tuple[str, str]:
184184 A pair of strings representing the opening and closing of the tex environment, e.g.
185185 ``\begin{tabular}{cccl}`` and ``\end{tabular}``
186186 """
187- environment .removeprefix (r"\begin" ).removeprefix ("{" )
187+ environment = environment .removeprefix (r"\begin" ).removeprefix ("{" )
188188
189189 # The \begin command takes everything and closes with a brace
190190 begin = r"\begin{" + environment
Original file line number Diff line number Diff line change 11import pytest
22
3- from manim .utils .tex import TexTemplate
3+ from manim .utils .tex import TexTemplate , _texcode_for_environment
44
55DEFAULT_BODY = r"""\documentclass[preview]{standalone}
66\usepackage[english]{babel}
@@ -116,3 +116,27 @@ def test_tex_template_fixed_body():
116116 match = "This TeX template was created with a fixed body, trying to add text the document will have no effect." ,
117117 ):
118118 template .add_to_document ("dummy" )
119+
120+
121+ def test_texcode_for_environment ():
122+ """Test that the environment is correctly extracted from the input"""
123+ # environment without arguments
124+ assert _texcode_for_environment ("align*" ) == (r"\begin{align*}" , r"\end{align*}" )
125+ assert _texcode_for_environment ("{align*}" ) == (r"\begin{align*}" , r"\end{align*}" )
126+ assert _texcode_for_environment (r"\begin{align*}" ) == (
127+ r"\begin{align*}" ,
128+ r"\end{align*}" ,
129+ )
130+ # environment with arguments
131+ assert _texcode_for_environment ("{tabular}[t]{cccl}" ) == (
132+ r"\begin{tabular}[t]{cccl}" ,
133+ r"\end{tabular}" ,
134+ )
135+ assert _texcode_for_environment ("tabular}{cccl" ) == (
136+ r"\begin{tabular}{cccl}" ,
137+ r"\end{tabular}" ,
138+ )
139+ assert _texcode_for_environment (r"\begin{tabular}[t]{cccl}" ) == (
140+ r"\begin{tabular}[t]{cccl}" ,
141+ r"\end{tabular}" ,
142+ )
You can’t perform that action at this time.
0 commit comments