diff --git a/orvanitag/cmd.py b/orvanitag/cmd.py index 9cb259e..cf976fd 100644 --- a/orvanitag/cmd.py +++ b/orvanitag/cmd.py @@ -79,7 +79,8 @@ def mktable(query: str, index: dict, filter=None, trunc_len: int=25): else: elements.append(None) - table.add_row(*elements) + # Cells are read as rich markup, so [brackets] in names and notes need escaping + table.add_row(*[escape(element) if element else element for element in elements]) console.print(table) else: console.print(f":thinking_face: [red]No results found for [white]{query}") diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 6f30fad..a4bbad3 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -170,3 +170,12 @@ def test_cmd_user_errors_exit_with_1(cwd, monkeypatch, capsys): main() assert exit.value.code == 1 assert "File missing.mp3 doesn't exist." in capsys.readouterr().out + + +def test_cmd_list_shows_square_brackets(cwd, monkeypatch, capsys): + (cwd / 'a [demo].mp3').touch() + OrvaniTag().add('a [demo].mp3', '#lofi', 'note', '[with]', 'brackets') + monkeypatch.setattr(sys, 'argv', ['otag', 'ls', '#lofi']) + main() + out = capsys.readouterr().out + assert 'a [demo].mp3' in out and '[with]' in out