Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Commit 5bff7c3

Browse files
committed
fix: CLI default value overrides TOML conf
1 parent 9d7c7a7 commit 5bff7c3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/mdformat_tables/plugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ def add_cli_argument_group(group: argparse._ArgumentGroup) -> None:
1212
`mdit.options["mdformat"]["plugin"]["tables"]`."""
1313
group.add_argument(
1414
"--compact-tables",
15-
action="store_true",
15+
action="store_const",
16+
const=True,
1617
help="do not add padding to table cells",
1718
)
1819

tests/test_parse.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,16 @@ def test_fixtures_compact__cli(line, title, text, expected, tmp_path):
5353
assert mdformat._cli.run([str(file_path), "--compact-tables"]) == 0
5454
md_new = file_path.read_text(encoding="utf-8")
5555
assert md_new == expected
56+
57+
58+
@pytest.mark.parametrize(
59+
"line,title,text,expected", fixtures_compact, ids=[f[1] for f in fixtures_compact]
60+
)
61+
def test_fixtures_compact__toml(line, title, text, expected, tmp_path):
62+
conf_path = tmp_path / ".mdformat.toml"
63+
conf_path.write_text("[plugin.tables]\ncompact_tables=true", encoding="utf-8")
64+
file_path = tmp_path / "test_markdown.md"
65+
file_path.write_text(text, encoding="utf-8")
66+
assert mdformat._cli.run([str(file_path)]) == 0
67+
md_new = file_path.read_text(encoding="utf-8")
68+
assert md_new == expected

0 commit comments

Comments
 (0)