Summary
Emit formatter output with the majority line-ending style from the input file.
mdtablefix currently emits Unix LF line endings regardless of the input file line endings.
Rationale
A formatter must not create a line-ending-only diff when the input file uses CRLF line endings. This behavior causes unnecessary changes in Windows-oriented repositories and prevents check-only formatting gates from comparing formatter output directly with valid CRLF source files.
Required changes
- Detect the line endings in each input Markdown file.
- Select the line-ending style that has the majority of line-ending occurrences in that file.
- Emit formatted output with the selected line-ending style.
- Preserve existing Markdown-formatting behavior.
- Define and document deterministic behavior when no line-ending style has a majority.
Affected areas
- Markdown input reading and output serialization.
- In-place formatting behavior.
- Formatter documentation, if it describes line-ending behavior.
- Automated tests for LF, CRLF, mixed-line-ending, and no-majority input.
Acceptance criteria
- A file with a majority of LF line endings produces LF output.
- A file with a majority of CRLF line endings produces CRLF output.
- A mixed-line-ending file produces output that uses its majority line-ending style.
- Tests cover both standard output and in-place formatting, where supported.
- Tests define the result for input with no majority line-ending style.
- Existing Markdown formatting behavior remains unchanged apart from output line-ending selection.
Backlinks
Summary
Emit formatter output with the majority line-ending style from the input file.
mdtablefixcurrently emits Unix LF line endings regardless of the input file line endings.Rationale
A formatter must not create a line-ending-only diff when the input file uses CRLF line endings. This behavior causes unnecessary changes in Windows-oriented repositories and prevents check-only formatting gates from comparing formatter output directly with valid CRLF source files.
Required changes
Affected areas
Acceptance criteria
Backlinks
@leynos