Add --list-spacing option for controlling tight/loose list formatting #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new
--list-spacingCLI option to control how tight vs loose list formatting is handled during Markdown normalization.Feature Plan: plan-2026-01-14-list-spacing-control.md
New Feature
preserveloosetightBREAKING CHANGE
The default behavior has changed from always making lists loose to preserving the original tight/loose formatting. Use
--list-spacing=looseto restore the previous behavior.Files Changed
Core Implementation:
src/flowmark/formats/flowmark_markdown.py- AddedListSpacingenum and modified list renderingsrc/flowmark/linewrapping/markdown_filling.py- Addedlist_spacingparametersrc/flowmark/reformat_api.py- Threaded parameter through APIsrc/flowmark/cli.py- Added--list-spacingCLI argumentAutomated Testing
All 172 tests pass. The following test coverage was added in
tests/test_list_spacing.py:Preserve Mode Tests (default):
test_tight_list_preserved- Tight lists stay tighttest_loose_list_preserved- Loose lists stay loosetest_preserve_is_default- Confirm preserve is the defaulttest_numbered_list_preserve- Numbered lists preserve tightnessLoose Mode Tests:
test_tight_list_to_loose- Tight lists become loosetest_loose_list_stays_loose- Loose lists stay loosetest_numbered_list_to_loose- Numbered lists become looseTight Mode Tests:
test_loose_list_to_tight- Loose lists become tighttest_tight_list_stays_tight- Tight lists stay tighttest_multi_para_stays_loose_in_tight_mode- Multi-paragraph items force loose (CommonMark requirement)Nested List Tests:
test_nested_lists_independent_preserve- Each nested list independently preserves tightnesstest_nested_lists_loose_outer_tight_inner- Mixed outer/inner tightness preservedComplex Content Tests:
test_list_items_with_code_blocks_preserve- Code blocks preserve tightnesstest_list_items_with_code_blocks_loose- Code blocks with loose modetest_list_items_with_quote_blocks- Quote blocks preserve tightnessSpacing Normalization Tests:
test_input_spacing_normalization_loose- Various input spacings normalize to loosetest_input_spacing_normalization_tight- Various input spacings normalize to tightOther Updated Tests:
test_escape_handling.py- Updated for backward compatibilitytest_filling.py- Updated for backward compatibilitytest_heading_spacing.py- Updated for backward compatibilityManual Validation
All core functionality is covered by automated tests. Manual review is only needed for:
flowmark --helpto confirm the--list-spacingoption description is clearTest Results
make lintpassesmake testpasses