Repository: jackdewinter/pymarkdown

Issue:
Markdown: Text indents in wrong places.
Found by https://github.com/jackdewinter/pymarkdown/issues/261 :

Tests
- test_nested_three_ordered_nl_block_skip_nl_block_skip
- test_nested_three_unordered_nl_block_skip_nl_block_skip

Discussion:

Patch:
diff --git a/changelog.md b/changelog.md
index ba87af6d..637fcbe8 100644
--- a/changelog.md
+++ b/changelog.md
@@ -47,6 +47,8 @@
   - parser: with empty list items, was creating 2 blank line tokens, plus extra list indent
 - [Fixed - Issue 265](https://github.com/jackdewinter/pymarkdown/issues/265)
   - parser: fixed with work on [Issue 262](https://github.com/jackdewinter/pymarkdown/issues/262)
+- [Fixed - Issue 268](https://github.com/jackdewinter/pymarkdown/issues/268)
+  - parser: previous work took too many newlnes out, this put the right ones back in
 
 ## Version 0.9.4 - Date: 2022-01-04
 
diff --git a/publish/coverage.json b/publish/coverage.json
index b3189ca7..02f18a76 100644
--- a/publish/coverage.json
+++ b/publish/coverage.json
@@ -2,12 +2,12 @@
     "projectName": "pymarkdown",
     "reportSource": "pytest",
     "branchLevel": {
-        "totalMeasured": 3014,
-        "totalCovered": 3014
+        "totalMeasured": 3016,
+        "totalCovered": 3016
     },
     "lineLevel": {
-        "totalMeasured": 10522,
-        "totalCovered": 10522
+        "totalMeasured": 10524,
+        "totalCovered": 10524
     }
 }
 
diff --git a/pymarkdown/block_quote_processor.py b/pymarkdown/block_quote_processor.py
index 9d6e6e24..af3da18a 100644
--- a/pymarkdown/block_quote_processor.py
+++ b/pymarkdown/block_quote_processor.py
@@ -1142,6 +1142,14 @@ class BlockQuoteProcessor:
         POGGER.debug("handle_block_quote_section>>leaf_tokens>>$", leaf_tokens)
         assert not (requeue_line_info and requeue_line_info.lines_to_requeue)
 
+        # KLUDGE!
+        if (
+            len(parser_state.token_stack) == 3
+            and parser_state.token_stack[1].is_list
+            and parser_state.token_stack[2].is_block_quote
+        ):
+            parser_state.token_stack[1].matching_markdown_token.add_leading_spaces("")
+
         return True, leaf_tokens
 
     @staticmethod


Test patch:
diff --git a/publish/test-results.json b/publish/test-results.json
index 6e4bcbb8..f8219d66 100644
--- a/publish/test-results.json
+++ b/publish/test-results.json
@@ -495,7 +495,7 @@
             "totalTests": 80,
             "failedTests": 0,
             "errorTests": 0,
-            "skippedTests": 2,
+            "skippedTests": 1,
             "elapsedTimeInMilliseconds": 0
         },
         {
diff --git a/test/test_markdown_lists.py b/test/test_markdown_lists.py
index 770c9fa0..094fd55b 100644
--- a/test/test_markdown_lists.py
+++ b/test/test_markdown_lists.py
@@ -2177,7 +2177,7 @@ def test_list_items_300x():
   >
 * c"""
     expected_tokens = [
-        "[ulist(1,1):*::2::]",
+        "[ulist(1,1):*::2::\n]",
         "[para(1,3):]",
         "[text(1,3):a:]",
         "[end-para:::True]",
@@ -2218,7 +2218,7 @@ def test_list_items_300a():
   >
 1) c"""
     expected_tokens = [
-        "[ulist(1,1):*::2::]",
+        "[ulist(1,1):*::2::\n]",
         "[para(1,3):]",
         "[text(1,3):a:]",
         "[end-para:::True]",
@@ -2262,7 +2262,7 @@ def test_list_items_300b():
   >
   * c"""
     expected_tokens = [
-        "[ulist(1,1):*::2::]",
+        "[ulist(1,1):*::2::\n]",
         "[para(1,3):]",
         "[text(1,3):a:]",
         "[end-para:::True]",
@@ -2568,7 +2568,7 @@ def test_list_items_301d():
   >     c
 - d"""
     expected_tokens = [
-        "[ulist(1,1):-::2::\n]",
+        "[ulist(1,1):-::2::\n\n]",
         "[para(1,3):]",
         "[text(1,3):a:]",
         "[end-para:::True]",
diff --git a/test/test_markdown_nested_three_ordered_block.py b/test/test_markdown_nested_three_ordered_block.py
index 98c9b433..11c502b5 100644
--- a/test/test_markdown_nested_three_ordered_block.py
+++ b/test/test_markdown_nested_three_ordered_block.py
@@ -57,7 +57,7 @@ def test_nested_three_ordered_nl_block_nl_unordered():
    > + list
    >   item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3:]",
+        "[olist(1,1):.:1:3::]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >\n   > \n   > ]",
         "[BLANK(2,5):]",
@@ -97,7 +97,7 @@ def test_nested_three_ordered_nl_block_nl_unordered_wo_bq():
      + list
    >   item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3::]",
+        "[olist(1,1):.:1:3::\n]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >]",
         "[BLANK(2,5):]",
@@ -277,7 +277,7 @@ def test_nested_three_ordered_nl_block_skip_nl_unordered():
    > + list
        item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3:]",
+        "[olist(1,1):.:1:3::]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >\n   > \n]",
         "[BLANK(2,5):]",
@@ -317,7 +317,7 @@ def test_nested_three_ordered_nl_block_skip_nl_unordered_wo_bq():
      + list
        item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3:]",
+        "[olist(1,1):.:1:3::]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >]",
         "[BLANK(2,5):]",
@@ -483,7 +483,7 @@ def test_nested_three_ordered_nl_block_nl_ordered():
    > 1. list
    >    item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3:]",
+        "[olist(1,1):.:1:3::]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >\n   > \n   > ]",
         "[BLANK(2,5):]",
@@ -523,7 +523,7 @@ def test_nested_three_ordered_nl_block_nl_ordered_wo_bq():
      1. list
    >    item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3::]",
+        "[olist(1,1):.:1:3::\n]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >]",
         "[BLANK(2,5):]",
@@ -703,7 +703,7 @@ def test_nested_three_ordered_nl_block_skip_nl_ordered():
    > 1. list
         item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3:]",
+        "[olist(1,1):.:1:3::]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >\n   > \n]",
         "[BLANK(2,5):]",
@@ -743,7 +743,7 @@ def test_nested_three_ordered_nl_block_skip_nl_ordered_wo_bq():
      1. list
         item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3:]",
+        "[olist(1,1):.:1:3::]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >]",
         "[BLANK(2,5):]",
@@ -909,7 +909,7 @@ def test_nested_three_ordered_nl_block_nl_block_x():
    > > list
    > > item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3::\n]",
+        "[olist(1,1):.:1:3::\n\n]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >]",
         "[BLANK(2,5):]",
@@ -949,7 +949,7 @@ def test_nested_three_ordered_nl_block_nl_block_wo_bq():
      > list
    > > item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3::\n]",
+        "[olist(1,1):.:1:3::\n\n]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >\n     > ]",
         "[BLANK(2,5):]",
@@ -1118,7 +1118,7 @@ def test_nested_three_ordered_nl_block_skip_nl_block():
    > > list
      > item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3::\n]",
+        "[olist(1,1):.:1:3::\n\n]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >]",
         "[BLANK(2,5):]",
@@ -1158,7 +1158,7 @@ def test_nested_three_ordered_nl_block_skip_nl_block_wo_bq():
      > list
      > item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3::\n]",
+        "[olist(1,1):.:1:3::\n\n]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >\n     > \n     > ]",
         "[BLANK(2,5):]",
@@ -1313,7 +1313,7 @@ def test_nested_three_ordered_nl_block_nl_block_skip():
    > > list
    >   item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3::\n]",
+        "[olist(1,1):.:1:3::\n\n]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >]",
         "[BLANK(2,5):]",
@@ -1353,7 +1353,7 @@ def test_nested_three_ordered_nl_block_nl_block_skip_wo_bq():
      > list
    >   item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3::\n]",
+        "[olist(1,1):.:1:3::\n\n]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >\n     > \n   > ]",
         "[BLANK(2,5):]",
@@ -1496,7 +1496,6 @@ item</p>
 
 
 @pytest.mark.gfm
-@pytest.mark.skip
 def test_nested_three_ordered_nl_block_skip_nl_block_skip():
     """
     Verify that a nesting of ordered list, block quote, block quote works
@@ -1509,7 +1508,7 @@ def test_nested_three_ordered_nl_block_skip_nl_block_skip():
    > > list
        item"""
     expected_tokens = [
-        "[olist(1,1):.:1:3::\n   \n]",
+        "[olist(1,1):.:1:3::\n\n   \n]",
         "[BLANK(1,3):]",
         "[block-quote(2,4):   :   >]",
         "[BLANK(2,5):]",
@@ -1533,7 +1532,7 @@ item</p>
 </ol>"""
 
     # Act & Assert
-    act_and_assert(source_markdown, expected_gfm, expected_tokens)
+    act_and_assert(source_markdown, expected_gfm, expected_tokens, show_debug=False)
 
 
 @pytest.mark.gfm
diff --git a/test/test_markdown_nested_three_unordered_block.py b/test/test_markdown_nested_three_unordered_block.py
index 17ee8130..fb2b5c5b 100644
--- a/test/test_markdown_nested_three_unordered_block.py
+++ b/test/test_markdown_nested_three_unordered_block.py
@@ -57,7 +57,7 @@ def test_nested_three_unordered_nl_block_nl_unordered():
   > + list
   >   item"""
     expected_tokens = [
-        "[ulist(1,1):+::2:]",
+        "[ulist(1,1):+::2::]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >\n  > \n  > ]",
         "[BLANK(2,4):]",
@@ -97,7 +97,7 @@ def test_nested_three_unordered_nl_block_nl_unordered_wo_bq():
     + list
   >   item"""
     expected_tokens = [
-        "[ulist(1,1):+::2::]",
+        "[ulist(1,1):+::2::\n]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >]",
         "[BLANK(2,4):]",
@@ -277,7 +277,7 @@ def test_nested_three_unordered_nl_block_skip_nl_unordered():
     + list
       item"""
     expected_tokens = [
-        "[ulist(1,1):+::2:]",
+        "[ulist(1,1):+::2::]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >]",
         "[BLANK(2,4):]",
@@ -317,7 +317,7 @@ def test_nested_three_unordered_nl_block_skip_nl_unordered_wo_bq():
     + list
       item"""
     expected_tokens = [
-        "[ulist(1,1):+::2:]",
+        "[ulist(1,1):+::2::]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >]",
         "[BLANK(2,4):]",
@@ -483,7 +483,7 @@ def test_nested_three_unordered_nl_block_nl_ordered():
   > 1. list
   >    item"""
     expected_tokens = [
-        "[ulist(1,1):+::2:]",
+        "[ulist(1,1):+::2::]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >\n  > \n  > ]",
         "[BLANK(2,4):]",
@@ -523,7 +523,7 @@ def test_nested_three_unordered_nl_block_nl_ordered_wo_bq():
     1. list
   >    item"""
     expected_tokens = [
-        "[ulist(1,1):+::2::]",
+        "[ulist(1,1):+::2::\n]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >]",
         "[BLANK(2,4):]",
@@ -703,7 +703,7 @@ def test_nested_three_unordered_nl_block_skip_nl_ordered():
     1. list
        item"""
     expected_tokens = [
-        "[ulist(1,1):+::2:]",
+        "[ulist(1,1):+::2::]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >]",
         "[BLANK(2,4):]",
@@ -743,7 +743,7 @@ def test_nested_three_unordered_nl_block_skip_nl_ordered_wo_bq():
     1. list
        item"""
     expected_tokens = [
-        "[ulist(1,1):+::2:]",
+        "[ulist(1,1):+::2::]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >]",
         "[BLANK(2,4):]",
@@ -909,7 +909,7 @@ def test_nested_three_unordered_nl_block_nl_block_x():
   > > list
   > > item"""
     expected_tokens = [
-        "[ulist(1,1):+::2::\n]",
+        "[ulist(1,1):+::2::\n\n]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >]",
         "[BLANK(2,4):]",
@@ -949,7 +949,7 @@ def test_nested_three_unordered_nl_block_nl_block_wo_bq():
     > list
   > > item"""
     expected_tokens = [
-        "[ulist(1,1):+::2::\n]",
+        "[ulist(1,1):+::2::\n\n]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >\n    > ]",
         "[BLANK(2,4):]",
@@ -1118,7 +1118,7 @@ def test_nested_three_unordered_nl_block_skip_nl_block_x():
   > > list
     > item"""
     expected_tokens = [
-        "[ulist(1,1):+::2::\n]",
+        "[ulist(1,1):+::2::\n\n]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >]",
         "[BLANK(2,4):]",
@@ -1158,7 +1158,7 @@ def test_nested_three_unordered_nl_block_skip_nl_block_wo_bq():
     > list
     > item"""
     expected_tokens = [
-        "[ulist(1,1):+::2::\n]",
+        "[ulist(1,1):+::2::\n\n]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >\n    > \n    > ]",
         "[BLANK(2,4):]",
@@ -1313,7 +1313,7 @@ def test_nested_three_unordered_nl_block_nl_block_skip():
   > > list
   >   item"""
     expected_tokens = [
-        "[ulist(1,1):+::2::\n]",
+        "[ulist(1,1):+::2::\n\n]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >]",
         "[BLANK(2,4):]",
@@ -1353,7 +1353,7 @@ def test_nested_three_unordered_nl_block_nl_block_skip_wo_bq():
     > list
   >   item"""
     expected_tokens = [
-        "[ulist(1,1):+::2::\n]",
+        "[ulist(1,1):+::2::\n\n]",
         "[BLANK(1,2):]",
         "[block-quote(2,3):  :  >\n    > \n  > ]",
         "[BLANK(2,4):]",
diff --git a/test/test_markdown_paragraph_series_n.py b/test/test_markdown_paragraph_series_n.py
index db1749ec..a9b5b49f 100644
--- a/test/test_markdown_paragraph_series_n.py
+++ b/test/test_markdown_paragraph_series_n.py
@@ -1130,7 +1130,7 @@ def test_paragraph_series_n_ul_t_nl_i2_bq_t_nl_bq_nl_i2_bq_ib():
   >     def
 * def"""
     expected_tokens = [
-        "[ulist(1,1):*::2::\n]",
+        "[ulist(1,1):*::2::\n\n]",
         "[para(1,3):]",
         "[text(1,3):abc:]",
         "[end-para:::True]",