diff --git a/tests/test_align.py b/tests/test_align.py index 3ef217e..677ea79 100644 --- a/tests/test_align.py +++ b/tests/test_align.py @@ -156,3 +156,30 @@ def test_tabular_math(): ret = texplain.indent(text) assert ret.strip() == formatted.strip() + + +def test_tabular_math_empty(): + text = r""" +\begin{tabular}{lll} + \toprule + Foo & Bar & Baz \\ + \midrule + $a$ & & $e$ \\ + $c'$ & $d = 2$ & $f'$ \\ + \bottomrule +\end{tabular} +""" + + formatted = r""" +\begin{tabular}{lll} + \toprule + Foo & Bar & Baz \\ + \midrule + $a$ & & $e$ \\ + $c'$ & $d = 2$ & $f'$ \\ + \bottomrule +\end{tabular} +""" + + ret = texplain.indent(text) + assert ret.strip() == formatted.strip() diff --git a/texplain/__init__.py b/texplain/__init__.py index 42f497b..1b19614 100644 --- a/texplain/__init__.py +++ b/texplain/__init__.py @@ -1160,10 +1160,18 @@ def _align(text: str, placeholders: dict[list[Placeholder]] = {}, maxwidth: int line = re.split(r"((?