diff --git a/tests/test_indent_simple.py b/tests/test_indent_simple.py index bf35854..2150ce0 100644 --- a/tests/test_indent_simple.py +++ b/tests/test_indent_simple.py @@ -226,6 +226,42 @@ def test_environment_c(self): ret = texplain.indent(text) self.assertEqual(ret.strip(), formatted.strip()) + def test_environment_star_a(self): + text = r""" +\begin{figure*}[b] + \centering + \includegraphics[width=\linewidth]{example-image} +\end{figure*} + """ + + formatted = r""" +\begin{figure*}[b] + \centering + \includegraphics[width=\linewidth]{example-image} +\end{figure*} + """ + + ret = texplain.indent(text) + self.assertEqual(ret.strip(), formatted.strip()) + + def test_environment_star_b(self): + text = r""" +\begin{figure*}[b] +\centering +\includegraphics[width=\linewidth]{example-image} +\end{figure*} + """ + + formatted = r""" +\begin{figure*}[b] + \centering + \includegraphics[width=\linewidth]{example-image} +\end{figure*} + """ + + ret = texplain.indent(text) + self.assertEqual(ret.strip(), formatted.strip()) + def test_environment_nested_a(self): text = r""" Some text \begin{equation} \begin{split} a = b \end{split} \end{equation} some more text. diff --git a/texplain/__init__.py b/texplain/__init__.py index 93a4e72..5a19527 100644 --- a/texplain/__init__.py +++ b/texplain/__init__.py @@ -1593,8 +1593,8 @@ def indent( elif env == "document": continue else: - opening = r"\\begin{" + env + r"}" - closing = r"\\end{" + env + r"}" + opening = r"\\begin{" + re.escape(env) + r"}" + closing = r"\\end{" + re.escape(env) + r"}" indices = find_matching( text, opening,