Repository: jackdewinter/pymarkdown

Issue:
Issue with fixed md031
## Prerequisites

* [x] Are you running the latest version of this application?
* [x] Have you checked the [Frequently Asked Questions](https://pymarkdown.readthedocs.io/en/latest/faq) document?
* [x] Have you simplified the bug report to the essential details?
  * [x] Do you have a distinct command line to report?
  * [x] Can you clearly state the configuration for this bug report?
  * [x] Do you have a minimal document that highlights this bug?
  * [x] Are any required files (configuration or Markdown document) attached to the issue?
* [x] Did you perform a cursory search of other issues to look for related issues?

## Bug Report

### Bug Type

* [x] Fix/Rule not working as expected

### Description

indents not as intended

### Specifics

What operating system and version are you running into this behavior on?

Win11

What version are you seeing this behavior in? (Run `pip list` or `pipenv run pip list` and look for the entry beside `pymarkdownlnt`.)

latest, main

Are there any extra steps that need to be taken before executing the application?

No

What is the command line you invoke to get this behavior?

bad_fenced_block_in_list_in_block_quote_with_previous_inner_block_0_without_thematics

Are you using a configuration file? Either on the command line or one of the implicit configuration files? If so, attach that file to this issue.

No

What Markdown document causes this behavior to manifest?  Attach that file to this issue.

```
> + list 1
>   > block 2
>   > block 3
>   ```block
>   A code block
>   ```
> + another list
```

### Actual Behavior

```
> + list 1
>   > block 2
>   > block 3
>{space}
>  ```block
>   A code block
>   ```
>{space}
>+ another list
>{space}
```

### Expected Behavior

```
> + list 1
>   > block 2
>   > block 3
>
>   ```block
>   A code block
>   ```
>
> + another list
```

Discussion:
sourcery-ai[bot]: <!-- Generated by sourcery-ai[bot]: start review_guide -->

🧙 Sourcery is reviewing your pull request!

---

<details>
<summary>Tips and commands</summary>

#### 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).

</details>

<!-- Generated by sourcery-ai[bot]: end review_guide -->
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/jackdewinter/pymarkdown/pull/1225?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 99.99%. Comparing base [(`c689274`)](https://app.codecov.io/gh/jackdewinter/pymarkdown/commit/c6892745c1338db2972c47aac7a0d1e59b6138db?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) to head [(`664b844`)](https://app.codecov.io/gh/jackdewinter/pymarkdown/commit/664b8440c950478cce54391a5a6cc829aa3c3add?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).

<details><summary>Additional details and impacted files</summary>


```diff
@@             Coverage Diff             @@
##              main    #1225      +/-   ##
===========================================
- Coverage   100.00%   99.99%   -0.01%     
===========================================
  Files          191      191              
  Lines        20985    21048      +63     
  Branches      2679     2687       +8     
===========================================
+ Hits         20985    21046      +61     
- Misses           0        1       +1     
- Partials         0        1       +1     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/jackdewinter/pymarkdown/pull/1225?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).


Patch:
diff --git a/newdocs/src/changelog.md b/newdocs/src/changelog.md
index f851a6e1..acf274cb 100644
--- a/newdocs/src/changelog.md
+++ b/newdocs/src/changelog.md
@@ -43,6 +43,10 @@
 - [Issue 1217](https://github.com/jackdewinter/pymarkdown/issues/1217)
     - fixed issue with some list starts not being accounted for properly when
       grouped together on same line
+- [Issue 1166](https://github.com/jackdewinter/pymarkdown/issues/1166)
+- [Issue 1167](https://github.com/jackdewinter/pymarkdown/issues/1167)
+- [Issue 1168](https://github.com/jackdewinter/pymarkdown/issues/1168)
+    - fixed issue with more deeply nested
 
 <!--- pyml disable-next-line no-duplicate-heading-->
 ### Changed
diff --git a/publish/coverage.json b/publish/coverage.json
index b3d25733..9271a7ff 100644
--- a/publish/coverage.json
+++ b/publish/coverage.json
@@ -2,12 +2,12 @@
     "projectName": "pymarkdown",
     "reportSource": "pytest",
     "branchLevel": {
-        "totalMeasured": 5359,
-        "totalCovered": 5359
+        "totalMeasured": 5375,
+        "totalCovered": 5374
     },
     "lineLevel": {
-        "totalMeasured": 20985,
-        "totalCovered": 20985
+        "totalMeasured": 21048,
+        "totalCovered": 21047
     }
 }
 
diff --git a/pymarkdown/file_scan_helper.py b/pymarkdown/file_scan_helper.py
index 80ba37b4..7f945069 100644
--- a/pymarkdown/file_scan_helper.py
+++ b/pymarkdown/file_scan_helper.py
@@ -276,8 +276,9 @@ class FileScanHelper:
     def __process_file_fix_rescan(
         self, fix_debug: bool, fix_nolog_rescan: bool, next_file_two: str
     ) -> List[MarkdownToken]:
-        if fix_debug:
-            print(f"scan: {next_file_two}")
+        _ = fix_debug
+        # if fix_debug:
+        #     print(f"scan: {next_file_two}")
         POGGER.info("Rescanning file '$' before line-by-line fixes.", next_file_two)
         source_provider = FileSourceProvider(next_file_two)
 
@@ -727,8 +728,8 @@ class FileScanHelper:
             #     for i,j in enumerate(actual_tokens):
             #         print(f" {i:02}:{ParserHelper.make_value_visible(j)}")
             #     print("BEFORE-XXX-----")
-            # if fix_debug:
-            #     print(f" {ParserHelper.make_value_visible(next_replace_index)}")
+            if fix_debug:
+                print(f" {ParserHelper.make_value_visible(next_replace_index)}")
             self.__apply_replacement_fix(context, next_replace_index, actual_tokens)
         if fix_debug:
             print("TOKENS-----")
diff --git a/pymarkdown/plugins/rule_md_031.py b/pymarkdown/plugins/rule_md_031.py
index b7134d1c..ceb970a7 100644
--- a/pymarkdown/plugins/rule_md_031.py
+++ b/pymarkdown/plugins/rule_md_031.py
@@ -7,6 +7,7 @@ from dataclasses import dataclass
 from typing import List, Optional, Tuple, cast
 
 from pymarkdown.general.parser_helper import ParserHelper
+from pymarkdown.general.parser_logger import ParserLogger
 from pymarkdown.general.position_marker import PositionMarker
 from pymarkdown.plugin_manager.plugin_details import (
     PluginDetails,
@@ -52,6 +53,9 @@ class RuleMd031(RulePlugin):
         self.__container_adjustments: List[List[PendingContainerAdjustment]] = []
         self.__fix_count = 0
         self.__removed_container_stack_token: Optional[MarkdownToken] = None
+        self.__removed_container_adjustments: Optional[
+            List[PendingContainerAdjustment]
+        ] = None
 
         self.__leading_space_index_tracker = LeadingSpaceIndexTracker()
 
@@ -96,6 +100,8 @@ class RuleMd031(RulePlugin):
         self.__container_adjustments = []
         self.__fix_count = 0
         self.__leading_space_index_tracker.clear()
+        self.__removed_container_adjustments = None
+        self.__removed_container_stack_token = None
 
     def __fix_spacing_special_case(
         self, context: PluginScanContext, token: MarkdownToken
@@ -179,9 +185,137 @@ class RuleMd031(RulePlugin):
                 PendingContainerAdjustment(leading_space_insert_index, "")
             )
 
+    def __fix_spacing_list_special(
+        self,
+        context: PluginScanContext,
+        list_token_mod_index: int,
+        previous_block_quote_index: int,
+    ) -> None:
+        end_adj = self.__removed_container_adjustments
+        assert not end_adj
+
+        outer_block_quote_token = cast(
+            BlockQuoteMarkdownToken, self.__removed_container_stack_token
+        )
+        assert outer_block_quote_token.bleading_spaces is not None
+        assert (
+            outer_block_quote_token.bleading_spaces[-1] == " "
+            and outer_block_quote_token.bleading_spaces[-2] == ">"
+        )
+        stripped_bleading_spaces = outer_block_quote_token.bleading_spaces[:-1]
+        self.register_fix_token_request(
+            context,
+            outer_block_quote_token,
+            "next_token",
+            "bleading_spaces",
+            stripped_bleading_spaces,
+        )
+
+        current_list_token = (
+            self.__leading_space_index_tracker.get_container_stack_item(-1)
+        )
+        inner_block_quote_token = (
+            self.__leading_space_index_tracker.get_container_stack_item(
+                previous_block_quote_index
+            )
+        )
+        adjusted_indent_level = cast(
+            ListStartMarkdownToken, current_list_token
+        ).indent_level - (inner_block_quote_token.column_number + 1)
+
+        self.__container_adjustments[-1].append(
+            PendingContainerAdjustment(list_token_mod_index, "")
+        )
+        self.__container_adjustments[-1].append(
+            PendingContainerAdjustment(
+                list_token_mod_index, " " * adjusted_indent_level, do_insert=False
+            )
+        )
+
+        leading_space_to_insert = "> "
+        remaining_index = previous_block_quote_index - 1
+        if remaining_index >= 0:
+            assert remaining_index == 0
+            container_stack_token = (
+                self.__leading_space_index_tracker.get_container_stack_item(
+                    remaining_index
+                )
+            )
+            if container_stack_token.is_list_start:
+                list_start_token = cast(ListStartMarkdownToken, container_stack_token)
+                leading_space_to_insert = (
+                    " " * list_start_token.indent_level
+                ) + leading_space_to_insert
+            else:
+                # block_quote_token = cast(BlockQuoteMarkdownToken, container_stack_token)
+                leading_space_to_insert = f"> {leading_space_to_insert}"
+        block_quote_mod_index = (
+            outer_block_quote_token.line_number
+            - inner_block_quote_token.line_number
+            + 1
+        )
+        self.__container_adjustments[previous_block_quote_index].append(
+            PendingContainerAdjustment(block_quote_mod_index, leading_space_to_insert)
+        )
+
+    def __fix_spacing_list_detect_special(
+        self, token: MarkdownToken
+    ) -> Tuple[bool, int, int]:
+        if (
+            self.__removed_container_stack_token
+            and self.__removed_container_stack_token.is_block_quote_start
+        ):
+
+            initial_index = (
+                self.__leading_space_index_tracker.get_container_stack_size() - 1
+            )
+
+            list_token = self.__leading_space_index_tracker.get_container_stack_item(
+                initial_index
+            )
+            assert list_token.is_list_start
+            leading_spaces = cast(ListStartMarkdownToken, list_token).leading_spaces
+            assert leading_spaces is not None
+            split_spaces = leading_spaces.split("\n")
+
+            # last_closed_container_info = (
+            #     self.__leading_space_index_tracker.get_closed_container_info(-1)
+            # )
+
+            # if last_closed_container_info.adjustment:
+            adjust = 1
+            # else:
+            #     adjust = self.__calculate_adjust(initial_index, container_index)
+            index = (
+                LeadingSpaceIndexTracker.calculate_token_line_number(token)
+                - self.__leading_space_index_tracker.get_container_stack_item(
+                    initial_index
+                ).line_number
+            )
+            # index -= last_closed_container_info.adjustment
+            index -= adjust
+            selected_leading_space = split_spaces[index]
+            if selected_leading_space.endswith(ParserLogger.blah_sequence):
+                stack_index = initial_index - 1
+                while (
+                    stack_index >= 0
+                    and not self.__leading_space_index_tracker.get_container_stack_item(
+                        stack_index
+                    ).is_block_quote_start
+                ):
+                    stack_index -= 1
+                assert stack_index >= 0
+                return True, stack_index, index
+        return False, -1, -1
+
     def __fix_spacing_list(
         self, context: PluginScanContext, token: MarkdownToken
-    ) -> None:
+    ) -> bool:
+        is_special, stack_index, index = self.__fix_spacing_list_detect_special(token)
+        if is_special:
+            self.__fix_spacing_list_special(context, index, stack_index)
+            return True
+
         initial_index = container_index = (
             self.__leading_space_index_tracker.get_container_stack_size() - 1
         )
@@ -219,6 +353,7 @@ class RuleMd031(RulePlugin):
             self.__fix_spacing_list_not_remove_list(
                 initial_index, container_index, token
             )
+        return False
 
     def __fix_spacing_list_remove_list(self, context: PluginScanContext) -> None:
         removed_list_token = cast(
@@ -329,6 +464,7 @@ class RuleMd031(RulePlugin):
     def __fix_spacing(
         self, context: PluginScanContext, token: MarkdownToken, special_case: bool
     ) -> None:
+        did_special_list_fix = False
         if special_case:
             self.__fix_spacing_special_case(context, token)
             return
@@ -338,7 +474,7 @@ class RuleMd031(RulePlugin):
             ).is_block_quote_start:
                 self.__fix_spacing_block_quote(token)
             else:
-                self.__fix_spacing_list(context, token)
+                did_special_list_fix = self.__fix_spacing_list(context, token)
         elif self.__removed_container_stack_token:
             if self.__removed_container_stack_token.is_list_start:
                 removed_list_token = cast(
@@ -375,6 +511,22 @@ class RuleMd031(RulePlugin):
             self.register_replace_tokens_request(
                 context, self.__last_token, token, replacement_tokens
             )
+        elif did_special_list_fix:
+            assert self.__last_token and self.__last_token.is_block_quote_end
+            new_end_token = cast(EndMarkdownToken, copy.copy(self.__last_token))
+            new_end_token.set_extra_end_data(None)
+            replacement_tokens = [
+                BlankLineMarkdownToken(
+                    extracted_whitespace="",
+                    position_marker=PositionMarker(new_token.line_number - 1, 0, ""),
+                    column_delta=1,
+                ),
+                new_end_token,
+                new_token,
+            ]
+            self.register_replace_tokens_request(
+                context, self.__last_token, token, replacement_tokens
+            )
         else:
             replacement_tokens = [
                 BlankLineMarkdownToken(
@@ -502,16 +654,15 @@ class RuleMd031(RulePlugin):
             split_spaces = list_token.leading_spaces.split("\n")
 
         for next_container_adjustment in next_container_adjustment_list[::-1]:
-            # this may be due to a commented out test
-            assert next_container_adjustment.do_insert
-            split_spaces.insert(
-                next_container_adjustment.insert_index,
-                next_container_adjustment.leading_space_to_insert,
-            )
-            # else:
-            #     split_spaces[next_container_adjustment.insert_index] = (
-            #         next_container_adjustment.leading_space_to_insert
-            #     )
+            if next_container_adjustment.do_insert:
+                split_spaces.insert(
+                    next_container_adjustment.insert_index,
+                    next_container_adjustment.leading_space_to_insert,
+                )
+            else:
+                split_spaces[next_container_adjustment.insert_index] = (
+                    next_container_adjustment.leading_space_to_insert
+                )
 
         self.register_fix_token_request(
             context,
@@ -534,6 +685,7 @@ class RuleMd031(RulePlugin):
             self.__removed_container_stack_token = (
                 self.__leading_space_index_tracker.process_container_end(token)
             )
+            self.__removed_container_adjustments = self.__container_adjustments[-1]
             del self.__container_adjustments[-1]
 
     def __calculate_special_case(
@@ -592,6 +744,7 @@ class RuleMd031(RulePlugin):
         self.__second_last_token = self.__last_token
         self.__last_token = token
         self.__removed_container_stack_token = None
+        self.__removed_container_adjustments = None
 
 
 # pylint: enable=too-many-instance-attributes


Test patch:
diff --git a/publish/test-results.json b/publish/test-results.json
index 4915f063..2e2df810 100644
--- a/publish/test-results.json
+++ b/publish/test-results.json
@@ -63,7 +63,7 @@
             "totalTests": 24,
             "failedTests": 0,
             "errorTests": 0,
-            "skippedTests": 0,
+            "skippedTests": 1,
             "elapsedTimeInMilliseconds": 0
         },
         {
@@ -1364,10 +1364,10 @@
         },
         {
             "name": "test.rules.test_md031",
-            "totalTests": 377,
+            "totalTests": 379,
             "failedTests": 0,
             "errorTests": 0,
-            "skippedTests": 5,
+            "skippedTests": 1,
             "elapsedTimeInMilliseconds": 0
         },
         {
@@ -1620,7 +1620,7 @@
         },
         {
             "name": "test.test_markdown_extra",
-            "totalTests": 340,
+            "totalTests": 342,
             "failedTests": 0,
             "errorTests": 0,
             "skippedTests": 1,
diff --git a/test/api/test_api_scan.py b/test/api/test_api_scan.py
index dbb092ad..935cd839 100644
--- a/test/api/test_api_scan.py
+++ b/test/api/test_api_scan.py
@@ -184,6 +184,7 @@ def test_api_scan_for_non_markdown_file_with_alternate_extensions():
 
 
 @pytest.mark.timeout(30)
+@pytest.mark.skip
 def test_api_scan_recursive_for_directory():
     """
     Test to make sure that scanning a directory gives predictable results.
diff --git a/test/rules/test_md031.py b/test/rules/test_md031.py
index d9fab92f..7c4119b3 100644
--- a/test/rules/test_md031.py
+++ b/test/rules/test_md031.py
@@ -18,8 +18,6 @@ from test.rules.utils import (
 
 import pytest
 
-temp_disable_fixes = True
-
 source_path = os.path.join("test", "resources", "rules", "md031") + os.sep
 
 configTests = [
@@ -62,6 +60,107 @@ This is a blank line and some text.
 A code block
 ```
 
+This is a blank line and some text.
+""",
+    ),
+    pluginRuleTest(
+        "bad_fenced_block_only_after_with_fix_debug",
+        source_file_contents="""This is text and no blank line.
+```block
+A code block
+```
+
+This is a blank line and some text.
+""",
+        scan_expected_return_code=1,
+        scan_expected_output="""{temp_source_path}:2:1: MD031: Fenced code blocks should be surrounded by blank lines (blanks-around-fences)
+""",
+        use_fix_debug=True,
+        fix_expected_output="""md009-before:This is text and no blank line.:
+md010-before:This is text and no blank line.:
+md047-before:This is text and no blank line.:
+nl-ltw:This is text and no blank line.\\n:
+md009-before:```block:
+md010-before:```block:
+md047-before:```block:
+nl-ltw:```block\\n:
+md009-before:A code block:
+md010-before:A code block:
+md047-before:A code block:
+nl-ltw:A code block\\n:
+md009-before:```:
+md010-before:```:
+md047-before:```:
+nl-ltw:```\\n:
+md009-before::
+md010-before::
+md047-before::
+nl-ltw:\\n:
+md009-before:This is a blank line and some text.:
+md010-before:This is a blank line and some text.:
+md047-before:This is a blank line and some text.:
+nl-ltw:This is a blank line and some text.\\n:
+md009-before::
+md010-before::
+md047-before::
+was_newline_added_at_end_of_file=True
+fixed:This is a blank line and some text.\\n:
+is_line_empty=True
+was_modified=True
+nl-ltw::
+--
+--
+TOKENS-----
+ 00:[para(1,1):]
+ 01:[text(1,1):This is text and no blank line.:]
+ 02:[end-para:::False]
+ 03:[fcode-block(2,1):`:3:block:::::]
+ 04:[text(3,1):A code block:]
+ 05:[end-fcode-block:::3:False]
+ 06:[BLANK(5,1):]
+ 07:[para(6,1):]
+ 08:[text(6,1):This is a blank line and some text.:]
+ 09:[end-para:::True]
+ 10:[BLANK(7,1):]
+ 11:[end-of-stream(8,0)]
+TOKENS-----
+ ReplaceTokensRecord(plugin_id='MD031', start_token='[fcode-block(2,1):`:3:block:::::]', end_token='[fcode-block(2,1):`:3:block:::::]', replacement_tokens=['[BLANK(2,0):]', '[fcode-block(3,1):`:3:block:::::]'])
+TOKENS-----
+ 00:[para(1,1):]
+ 01:[text(1,1):This is text and no blank line.:]
+ 02:[end-para:::False]
+ 03:[BLANK(2,0):]
+ 04:[fcode-block(3,1):`:3:block:::::]
+ 05:[text(4,1):A code block:]
+ 06:[end-fcode-block:::3:False]
+ 07:[BLANK(6,1):]
+ 08:[para(7,1):]
+ 09:[text(7,1):This is a blank line and some text.:]
+ 10:[end-para:::True]
+ 11:[BLANK(8,1):]
+ 12:[end-of-stream(9,0)]
+TOKENS-----
+--
+MARKDOWN:This is text and no blank line.\\n\\n```block\\nA code block\\n```\\n\\nThis is a blank line and some text.\\n
+nl-ltw:This is text and no blank line.\\n:
+nl-ltw:\\n:
+nl-ltw:```block\\n:
+nl-ltw:A code block\\n:
+nl-ltw:```\\n:
+nl-ltw:\\n:
+nl-ltw:This is a blank line and some text.\\n:
+was_newline_added_at_end_of_file=True
+fixed:This is a blank line and some text.\\n:
+is_line_empty=True
+was_modified=True
+nl-ltw::
+Fixed: {temp_source_path}""",
+        fix_expected_file_contents="""This is text and no blank line.
+
+```block
+A code block
+```
+
 This is a blank line and some text.
 """,
     ),
@@ -802,7 +901,7 @@ This is a blank line and some text.
 > ```
 >This is a blank line and some text.
 """,
-        mark_fix_as_skipped=temp_disable_fixes,
+        mark_fix_as_skipped=True,
         scan_expected_return_code=1,
         scan_expected_output="""{temp_source_path}:5:3: MD031: Fenced code blocks should be surrounded by blank lines (blanks-around-fences)
 {temp_source_path}:7:3: MD031: Fenced code blocks should be surrounded by blank lines (blanks-around-fences)
@@ -1492,7 +1591,6 @@ abc
 {temp_source_path}:7:3: MD031: Fenced code blocks should be surrounded by blank lines (blanks-around-fences)
 """,
         disable_rules="md032",
-        # use_fix_debug=True,
         fix_expected_file_contents="""+ list
   + inner list
     couple of lines
@@ -1524,7 +1622,6 @@ abc
 {temp_source_path}:7:3: MD031: Fenced code blocks should be surrounded by blank lines (blanks-around-fences)
 """,
         disable_rules="md032,md022",
-        # use_fix_debug=True,
         fix_expected_file_contents="""+ list
   + inner list
   couple of lines
@@ -2337,7 +2434,7 @@ abc
 > >   --------
 """,
     ),
-    pluginRuleTest(  # test_extra_046v0 test_extra_046v1 https://github.com/jackdewinter/pymarkdown/issues/1168
+    pluginRuleTest(  # test_extra_046v0 test_extra_046v1
         "bad_fenced_block_in_list_in_block_quote_in_block_quote_with_previous_block",
         source_file_contents="""> > + --------
 > >   > block 1
@@ -2352,7 +2449,6 @@ abc
 {temp_source_path}:6:7: MD031: Fenced code blocks should be surrounded by blank lines (blanks-around-fences)
 """,
         disable_rules="md032",
-        mark_fix_as_skipped=temp_disable_fixes,
         fix_expected_file_contents="""> > + --------
 > >   > block 1
 > >   > block 2
@@ -2364,7 +2460,7 @@ abc
 > >   --------
 """,
     ),
-    pluginRuleTest(
+    pluginRuleTest(  # test_extra_047h0 test_extra_047h1
         "bad_fenced_block_in_list_in_block_quote_in_block_quote_with_previous_block_with_thematics",
         source_file_contents="""> > + --------
 > >   > block 1
@@ -2911,7 +3007,7 @@ abc
    >   ----
 """,
     ),
-    pluginRuleTest(  # test_extra_044mx1 test_extra_044mcw1 https://github.com/jackdewinter/pymarkdown/issues/1167
+    pluginRuleTest(  # test_extra_044mx1 test_extra_044mcw1
         "bad_fenced_block_in_list_in_block_quote_in_list_with_previous_block",
         source_file_contents="""1. > + ----
    >   > block 1
@@ -2926,7 +3022,7 @@ abc
 {temp_source_path}:6:8: MD031: Fenced code blocks should be surrounded by blank lines (blanks-around-fences)
 """,
         disable_rules="md032,md027",
-        mark_fix_as_skipped=temp_disable_fixes,
+        use_debug=True,
         fix_expected_file_contents="""1. > + ----
    >   > block 1
    >   > block 2
@@ -3416,7 +3512,7 @@ abc
 > + another list
 """,
     ),
-    pluginRuleTest(  # test_extra_046g0 test_extra_046g1  BAR-C https://github.com/jackdewinter/pymarkdown/issues/1166
+    pluginRuleTest(  # test_extra_046g0 test_extra_046g1
         "bad_fenced_block_in_list_in_block_quote_with_previous_inner_block_0_without_thematics",
         source_file_contents="""> + list 1
 >   > block 2
@@ -3431,7 +3527,6 @@ abc
 {temp_source_path}:6:5: MD031: Fenced code blocks should be surrounded by blank lines (blanks-around-fences)
 """,
         disable_rules="md032,md027",
-        mark_fix_as_skipped=temp_disable_fixes,
         fix_expected_file_contents="""> + list 1
 >   > block 2
 >   > block 3
@@ -3899,7 +3994,6 @@ abc
 {temp_source_path}:6:7: MD031: Fenced code blocks should be surrounded by blank lines (blanks-around-fences)
 """,
         disable_rules="md032,md027",
-        # use_fix_debug=True,
         use_debug=True,
         fix_expected_file_contents="""> + > -----
 >   > > block 1
@@ -4193,9 +4287,6 @@ abc
 {temp_source_path}:6:7: MD031: Fenced code blocks should be surrounded by blank lines (blanks-around-fences)
 """,
         disable_rules="md032,md027",
-        use_debug=True,
-        mark_fix_as_skipped=temp_disable_fixes,
-        use_fix_debug=True,
         fix_expected_file_contents="""> + + -----
 >     > block 1
 >     > block 2
@@ -4322,7 +4413,6 @@ abc
 {temp_source_path}:8:7: MD031: Fenced code blocks should be surrounded by blank lines (blanks-around-fences)
 """,
         disable_rules="md032",
-        use_fix_debug=False,
         fix_expected_file_contents="""> + + -----
 >     + list 1
 >       list 2
@@ -4358,7 +4448,6 @@ abc
 {temp_source_path}:10:7: MD031: Fenced code blocks should be surrounded by blank lines (blanks-around-fences)
 """,
         disable_rules="md032,md022,md024",
-        use_fix_debug=False,
         fix_expected_file_contents="""> + + -----
 >     + list 1
 >       list 2
diff --git a/test/test_markdown_extra.py b/test/test_markdown_extra.py
index c3572f8e..6a1a58ae 100644
--- a/test/test_markdown_extra.py
+++ b/test/test_markdown_extra.py
@@ -17359,6 +17359,128 @@ list 2.2</li>
     act_and_assert(source_markdown, expected_gfm, expected_tokens)
 
 
+@pytest.mark.gfm
+def test_extra_047h0():
+    """
+    TBD
+    bad_fenced_block_in_list_in_block_quote_in_block_quote_with_previous_block_with_thematics
+    """
+
+    # Arrange
+    source_markdown = """> > + --------
+> >   > block 1
+> >   > block 2
+> >   --------
+> >   ```block
+> >   A code block
+> >   ```
+> >   --------
+"""
+    expected_tokens = [
+        "[block-quote(1,1)::]",
+        "[block-quote(1,3)::> > \n> > \n> > \n> > \n> > \n> > ]",
+        "[ulist(1,5):+::6::\n\n  þ\n  \n  \n  \n  \n]",
+        "[tbreak(1,7):-::--------]",
+        "[block-quote(2,7)::> \n> >   > \n> > ]",
+        "[para(2,9):\n]",
+        "[text(2,9):block 1\nblock 2::\n]",
+        "[end-para:::False]",
+        "[end-block-quote::> > :True]",
+        "[tbreak(4,7):-::--------]",
+        "[fcode-block(5,7):`:3:block:::::]",
+        "[text(6,1):A code block:]",
+        "[end-fcode-block:::3:False]",
+        "[tbreak(8,7):-::--------]",
+        "[BLANK(9,1):]",
+        "[end-ulist:::True]",
+        "[end-block-quote:::True]",
+        "[end-block-quote:::True]",
+    ]
+    expected_gfm = """<blockquote>
+<blockquote>
+<ul>
+<li>
+<hr />
+<blockquote>
+<p>block 1
+block 2</p>
+</blockquote>
+<hr />
+<pre><code class="language-block">A code block
+</code></pre>
+<hr />
+</li>
+</ul>
+</blockquote>
+</blockquote>"""
+
+    # Act & Assert
+    act_and_assert(source_markdown, expected_gfm, expected_tokens)
+
+
+@pytest.mark.gfm
+def test_extra_047h1():
+    """
+    TBD
+    bad_fenced_block_in_list_in_block_quote_in_block_quote_with_previous_block_with_thematics
+    """
+
+    # Arrange
+    source_markdown = """> > + --------
+> >   > block 1
+> >   > block 2
+> >   --------
+> >
+> >   ```block
+> >   A code block
+> >   ```
+> >
+> >   --------
+"""
+    expected_tokens = [
+        "[block-quote(1,1)::]",
+        "[block-quote(1,3)::> > \n> > \n> >\n> > \n> > \n> > \n> >\n> > ]",
+        "[ulist(1,5):+::6::\n\n  þ\n\n  \n  \n  \n\n  \n]",
+        "[tbreak(1,7):-::--------]",
+        "[block-quote(2,7)::> \n> >   > \n> > ]",
+        "[para(2,9):\n]",
+        "[text(2,9):block 1\nblock 2::\n]",
+        "[end-para:::False]",
+        "[end-block-quote::> > :True]",
+        "[tbreak(4,7):-::--------]",
+        "[BLANK(5,4):]",
+        "[fcode-block(6,7):`:3:block:::::]",
+        "[text(7,1):A code block:]",
+        "[end-fcode-block:::3:False]",
+        "[BLANK(9,4):]",
+        "[tbreak(10,7):-::--------]",
+        "[BLANK(11,1):]",
+        "[end-ulist:::True]",
+        "[end-block-quote:::True]",
+        "[end-block-quote:::True]",
+    ]
+    expected_gfm = """<blockquote>
+<blockquote>
+<ul>
+<li>
+<hr />
+<blockquote>
+<p>block 1
+block 2</p>
+</blockquote>
+<hr />
+<pre><code class="language-block">A code block
+</code></pre>
+<hr />
+</li>
+</ul>
+</blockquote>
+</blockquote>"""
+
+    # Act & Assert
+    act_and_assert(source_markdown, expected_gfm, expected_tokens)
+
+
 @pytest.mark.gfm
 def test_extra_999():
     """