jackdewinter / pymarkdown

MIT License
75 stars 17 forks source link

https://github.com/jackdewinter/pymarkdown/issues/1233 #1241

Closed jackdewinter closed 3 weeks ago

jackdewinter commented 3 weeks ago

closes #1233 closes #1234 closes #1235

Summary by Sourcery

Fix block quote handling in container reduction and add comprehensive tests for nested structures with fenced code blocks.

Bug Fixes:

Tests:

sourcery-ai[bot] commented 3 weeks ago

Reviewer's Guide by Sourcery

This pull request addresses multiple issues related to handling nested block quotes, lists, and fenced code blocks in Markdown parsing. The changes primarily affect the test suite, adding numerous new test cases to cover various edge cases and scenarios. The main implementation changes are in the container_helper.py file, modifying how nested block quotes and lists are processed.

Class diagram for test cases in nested_three

classDiagram
    class TestMarkdownNestedThreeBlockUnorderedBlock {
        +test_nested_three_block_unordered_block_fenced_empty_with_thematics()
        +test_nested_three_block_unordered_block_fenced_empty_with_blanks_with_thematics()
        +test_nested_three_block_unordered_block_fenced_with_thematics()
        +test_nested_three_block_unordered_block_fenced_with_blanks_with_thematics()
        +test_nested_three_block_unordered_block_fenced_with_text_before_with_thematics()
        +test_nested_three_block_unordered_block_fenced_with_blanks_with_text_before_with_thematics()
        +test_nested_three_block_unordered_block_fenced_with_text_after_with_thematics()
        +test_nested_three_block_unordered_block_fenced_with_blanks_with_text_after_with_thematics()
        +test_nested_three_block_unordered_block_fenced_multiline_with_thematics()
        +test_nested_three_block_unordered_block_thematics_around_text_lines()
        +test_nested_three_block_unordered_block_thematics_around_blanks_around_text_lines()
        +test_nested_three_block_unordered_block_thematics_around_text_lines_with_text_after()
        +test_nested_three_block_unordered_nl_block_drop_block_thematics_around_fenced_code_block()
        +test_nested_three_block_unordered_nl_block_drop_block_thematics_around_blanks_around_fenced_code_block()
        +test_nested_three_block_unordered_block_extra_list__li_drop_list_thematics_around_fenced_code_block()
        +test_nested_three_block_unordered_block_extra_list__li_drop_list_thematics_around_blanks_around_fenced_code_block()
        +test_nested_three_block_unordered_block_extra_block_single_line_drop_block_thematics_around_fenced_code_block()
        +test_nested_three_block_unordered_block_extra_block_drop_block_thematics_around_fenced_code_block()
        +test_nested_three_block_unordered_block_extra_block_drop_block_thematics_around_blanks_around_fenced_code_block()
        +test_nested_three_block_unordered_block_extra_block_drop_block_with_fenced_code_block()
        +test_nested_three_block_unordered_block_extra_block_drop_block_with_blanks_around_fenced_code_block()
        +test_nested_three_block_unordered_block_extra_block_with_extra_single_indent_drop_block_with_fenced_code_block()
        +test_nested_three_block_unordered_block_extra_block_with_extra_double_indent_drop_block_with_fenced_code_block()
        +test_nested_three_block_unordered_block_extra_block_with_extra_triple_indent_drop_block_with_fenced_code_block()
        +test_nested_three_block_unordered_block_extra_block_drop_block_extra_block_drop_block_fenced()
        +test_nested_three_block_unordered_block_extra_block_drop_block_extra_block_drop_block_blanks_around_fenced()
        +test_nested_three_block_unordered_nl_block_drop_block_with_fenced()
        +test_nested_three_block_unordered_nl_block_drop_block_with_blanks_around_fenced()
        +test_nested_three_block_unordered_block_thematics_around_text_and_fenced()
        +test_nested_three_block_unordered_block_thematics_around_text_and_blanks_around_fenced()
        +test_nested_three_block_unordered_block_thematic_drop_block_and_list_with_text()
        +test_nested_three_block_unordered_block_thematic_nl_text_drop_block_and_list_with_text()
        +test_nested_three_block_unordered_block_thematic_nl_fenced_with_drop_block_li()
        +test_nested_three_block_unordered_block_fenced_with_drop_right_after()
        +test_nested_three_block_unordered_block_empty_fenced_with_drop_right_after()
        +test_nested_three_block_unordered_block_thematics_around_blanks_around_text_drop_block_li_li_extra_block_drop_block_li()
        +test_nested_three_block_unordered_block_thematics_around_blank_drop_block_li_text()
        +test_nested_three_block_unordered_block_thematics_around_blank_drop_block_li_extra_block_text()
        +test_nested_three_block_unordered_nl_block_drop_block_headings_around_fenced()
        +test_nested_three_block_unordered_nl_block_drop_block_blank_thematics_around_fenced()
        +test_nested_three_block_unordered_extra_block_with_no_space_after_drop_block_thematics_around_fenced()
        +test_nested_three_block_unordered_extra_block_drop_block_thematic_extra_block_drop_block_thematics_around_fenced()
        +test_nested_three_block_unordered_extra_list_drop_list_thematics_around_fenced()
    }

    class TestMarkdownNestedThreeOrderedBlockUnordered {
        +test_nested_three_ordered_block_unordered_nl_extra_block_drop_block_fenced()
        +test_nested_three_ordered_block_unordered_nl_extra_block_drop_block_blanks_around_fenced()
        +test_nested_three_ordered_block_unordered_thematics_around_fenced()
        +test_nested_three_ordered_block_unordered_extra_block_drop_block_with_headings_around_fenced()
        +test_nested_three_ordered_block_unordered_extra_list_li_drop_list_with_fenced()
        +test_nested_three_ordered_block_unordered_extra_list_li_drop_list_with_blanks_around_fenced()
        +test_nested_three_ordered_block_unordered_extra_list_li_drop_list_with_thematics_around_fenced()
        +test_nested_three_ordered_block_unordered_extra_list_li_drop_list_with_thematics_around_blanks_around_fenced()
        +test_nested_three_ordered_block_unordered_li_with_empty_prefix_extra_block_drop_block_headings_around_text()
        +test_nested_three_ordered_block_unordered_extra_block_drop_block_headings_around_text()
        +test_nested_three_ordered_block_unordered_thematics_around_headings_around_text()
        +test_nested_three_ordered_block_unordered_extra_block_drop_block_thematics_around_text()
        +test_nested_three_ordered_block_unordered_extra_block_drop_block_html_around_text()
    }

File-Level Changes

Change Details Files
Added new test cases for nested block quotes, lists, and fenced code blocks
  • Added tests for various combinations of nested block quotes, unordered lists, and fenced code blocks
  • Added tests for handling thematic breaks and HTML comments within nested structures
  • Added tests for different indentation levels and dropping of list items
test/rules/test_md031.py
test/nested_three/test_markdown_nested_three_block_unordered_block.py
test/nested_three/test_markdown_nested_three_block_unordered_unordered.py
test/nested_three/test_markdown_nested_three_block_block_unordered.py
Modified container block processing logic
  • Updated the __reduce_containers_if_required_bq_list function to handle both block quotes and lists
  • Changed the assertion in __reduce_containers_if_required_bq to count block quote tokens instead of total tokens
pymarkdown/container_blocks/container_helper.py
Updated code coverage metrics
  • Increased branch coverage from 5367 to 5385
  • Increased line coverage from 21037 to 21081
publish/coverage.json

Assessment against linked issues

Issue Objective Addressed Explanation
#1233 Add more tests to cover cases of Nested Containers and multi-level drops
#1233 Ensure proper handling of nested containers and multi-level drops by both the parser and rule Md031
#1234 Fix parsing issues for multiple-drops showing incorrect parsing
#1234 Add new test cases for multiple-drops scenarios
#1235 Fix asserts while scanning multiple drops in containers

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (3335836) to head (ec34bc6). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1241 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 191 191 Lines 21037 21081 +44 Branches 2683 2692 +9 ========================================= + Hits 21037 21081 +44 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.