Skip to content

Commit

Permalink
Correctly identifying starred environments
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus committed Nov 7, 2023
1 parent 2b6cbe0 commit 6695ca7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
14 changes: 14 additions & 0 deletions tests/test_classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ def test_figure(self):
tex.format_labels()
self.assertEqual(str(tex).strip(), text.strip())

def test_figure_b(self):
text = r"""
foo bar
\begin{figure*}
\label{fig:foo}
\caption{My caption}
\end{figure*}
baz
"""

tex = texplain.TeX(text)
tex.format_labels()
self.assertEqual(str(tex).strip(), text.strip())

def test_custom(self):
text = r"""
\begin{example}[H]
Expand Down
16 changes: 8 additions & 8 deletions texplain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1856,8 +1856,8 @@ def _classify_for_label(text: str) -> tuple[list[str], NDArray[np.int_]]:

index = find_matching(
text,
r"\begin{figure}",
r"\end{figure}",
r"\\begin\{figure\*?\}",
r"\\end\{figure\*?\}",
escape=True,
closing_match=1,
)
Expand All @@ -1870,8 +1870,8 @@ def _classify_for_label(text: str) -> tuple[list[str], NDArray[np.int_]]:

index = find_matching(
text,
r"\begin{table}",
r"\end{table}",
r"\\begin\{table\*?\}",
r"\\end\{table\*?\}",
escape=True,
closing_match=1,
)
Expand All @@ -1884,8 +1884,8 @@ def _classify_for_label(text: str) -> tuple[list[str], NDArray[np.int_]]:

index = find_matching(
text,
r"\begin{itemize}",
r"\end{itemize}",
r"\\begin\{itemize\*?\}",
r"\\end\{itemize\*?\}",
escape=True,
closing_match=1,
)
Expand All @@ -1894,8 +1894,8 @@ def _classify_for_label(text: str) -> tuple[list[str], NDArray[np.int_]]:

index = find_matching(
text,
r"\begin{enumerate}",
r"\end{enumerate}",
r"\\begin\{enumerate\*?\}",
r"\\end\{enumerate\*?\}",
escape=True,
closing_match=1,
)
Expand Down

0 comments on commit 6695ca7

Please sign in to comment.