-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
context
When I format a file via mdformat.file and pass the check option.
expectation
I expect the call to error-out if the file is not formatted similar to what the CLI does.
bug
Instead the file is always reformatted.
It would be great to have the API behave the same as the CLI to work in Python-based tooling w/o having to subprocess-call mdformat.
On a side-note, one can also specify arbitrary options that get silently ignored.
Reproduce the bug
from pathlib import Path
import mdformat
file = Path("ill_formatted.md")
file.write_text(" # TITLE WITH LEADING SPACES")
print(f"Before\n{file.read_text()}")
mdformat.file(file, options={"check": True})
print(f"After\n{file.read_text()}")
file.unlink()Output:
Before
# TITLE WITH LEADING SPACES
After
# TITLE WITH LEADING SPACES
List your environment
Python 3.13.2 & mdformat 0.7.22
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working