Closed jackdewinter closed 1 week ago
This PR fixes issues with the MD031 rule (fenced code blocks should be surrounded by blank lines) when handling nested containers and container drops. The changes improve the handling of leading spaces and indentation in various container scenarios.
classDiagram
class PendingContainerAdjustment {
int insert_index
string leading_space_to_insert
bool do_insert
bool do_special
}
classDiagram
class RuleMd031 {
List~List~PendingContainerAdjustment~~ __container_adjustments
int __fix_count
Optional~MarkdownToken~ __removed_container_stack_token
List~MarkdownToken~ __x1
List~List~PendingContainerAdjustment~~ __x2
List~int~ __x3
Optional~List~PendingContainerAdjustment~~ __removed_container_adjustments
List~MarkdownToken~ __last_end_container_tokens
LeadingSpaceIndexTracker __leading_space_index_tracker
void starting_new_file()
void __fix_spacing_special_case(PluginScanContext context, MarkdownToken token)
void __fix_spacing_block_quote(MarkdownToken token, bool upgrade_kludge)
bool __fix_spacing_one_container(PluginScanContext context, MarkdownToken token, bool upgrade_kludge)
void __fix_spacing_with_fenced_and_list_end(PluginScanContext context, MarkdownToken token, MarkdownToken new_token)
void __fix_spacing_with_special_list_fix(PluginScanContext context, MarkdownToken token, MarkdownToken new_token)
void __fix_spacing_with_else(PluginScanContext context, MarkdownToken token, MarkdownToken new_token)
bool __calc_kludge_one(bool at_least_one_container)
bool __calc_2(PluginScanContext context, bool did_process_removals)
Tuple~bool, bool~ __calc_3(PluginScanContext context, bool did_process_removals, bool at_least_one_container, bool upgrade_kludge)
bool __apply_tailing_block_quote_fix(int modify_index, PluginScanContext context)
void __fix_spacing(PluginScanContext context, MarkdownToken token, bool special_case)
void __handle_fenced_code_block(PluginScanContext context, MarkdownToken token, bool special_case)
void __process_pending_container_end_adjustment(PluginScanContext context, List~PendingContainerAdjustment~ next_container_adjustment_list)
void __process_pending_container_end_tokens(PluginScanContext context, List~PendingContainerAdjustment~ next_container_adjustment_list)
void next_token(PluginScanContext context, MarkdownToken token)
}
classDiagram
class TransformContainers {
static Optional~string~ __abcd_final_list_second_half(List~MarkdownToken~ removed_tokens, List~int~ removed_token_indices, List~MarkdownToken~ container_stack, Optional~string~ possible_prefix)
static Optional~string~ __abcd_final_list(List~MarkdownToken~ removed_tokens, List~int~ removed_token_indices, List~MarkdownToken~ container_stack)
static Optional~string~ __abcd_final(List~MarkdownToken~ removed_tokens, List~int~ removed_token_indices, List~MarkdownToken~ container_stack)
}
Change | Details | Files |
---|---|---|
Added support for handling special cases in block quote and list container drops |
|
pymarkdown/plugins/rule_md_031.py |
Improved container stack handling in transform containers |
|
pymarkdown/transform_markdown/transform_containers.py |
Added new test cases and updated existing ones |
|
test/test_markdown_extra.py test/rules/test_md031.py |
Issue | Objective | Addressed | Explanation |
---|---|---|---|
#1250 | Fix cases where dropping two containers on a single line produces incorrect Markdown for MD031 | ✅ |
Attention: Patch coverage is 98.91304%
with 1 line
in your changes missing coverage. Please review.
Project coverage is 99.98%. Comparing base (
50a1e94
) to head (ecef8f0
). Report is 1 commits behind head on main.
Files with missing lines | Patch % | Lines |
---|---|---|
pymarkdown/plugins/rule_md_031.py | 98.91% | 0 Missing and 1 partial :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
closes #1250
Summary by Sourcery
Enhance the Markdown transformation logic to better handle spacing for fenced code blocks within nested lists and block quotes, and add comprehensive test cases to ensure coverage of these scenarios.
Enhancements:
Documentation:
Tests: