Skip to content

Commit

Permalink
issue 1263 (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdewinter authored Nov 19, 2024
1 parent 5a8b409 commit 8f9eea1
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 30 deletions.
3 changes: 3 additions & 0 deletions newdocs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
- [Issue 1259](https://github.com/jackdewinter/pymarkdown/issues/1259)
- Fixed asserts and bad parsing from cases where containers are
added and then a "raw" blank line removes all containers
- [Issue 1263](https://github.com/jackdewinter/pymarkdown/issues/1263)
- Fixed issue where a new unordered list between two block quotes
was not being recognized properly.

<!--- pyml disable-next-line no-duplicate-heading-->
### Changed
Expand Down
8 changes: 4 additions & 4 deletions publish/coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"projectName": "pymarkdown",
"reportSource": "pytest",
"branchLevel": {
"totalMeasured": 5463,
"totalCovered": 5463
"totalMeasured": 5465,
"totalCovered": 5465
},
"lineLevel": {
"totalMeasured": 21304,
"totalCovered": 21304
"totalMeasured": 21307,
"totalCovered": 21307
}
}

2 changes: 1 addition & 1 deletion publish/test-results.json
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,7 @@
},
{
"name": "test.test_markdown_extra",
"totalTests": 257,
"totalTests": 261,
"failedTests": 0,
"errorTests": 0,
"skippedTests": 5,
Expand Down
16 changes: 14 additions & 2 deletions pymarkdown/block_quotes/block_quote_count_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,20 @@ def __is_special_double_block_case(
BlockQuoteCountHelper.__block_quote_character, start_index
)
POGGER.debug("+1>>next_bq_index:$:", next_bq_index)
if next_bq_index != -1 and (next_bq_index - start_index) <= 3:
continue_processing, start_index = True, next_bq_index
index_delta = next_bq_index - start_index
if next_bq_index != -1 and index_delta <= 3:
final_index, _ = ParserHelper.collect_while_spaces(
adjusted_line, start_index
)
if final_index == next_bq_index:
continue_processing, start_index = True, next_bq_index
else:
cast(
BlockQuoteMarkdownToken,
parser_state.token_stack[
final_stack_index
].matching_markdown_token,
).weird_kludge_seven = True
return continue_processing, start_index

@staticmethod
Expand Down
10 changes: 5 additions & 5 deletions pymarkdown/container_blocks/container_block_leaf_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,11 @@ def __adjust_for_list_container_after_block_quote_special_special(
BlockQuoteMarkdownToken,
parser_state.token_stack[bq_index].matching_markdown_token,
)
last_leading_space = xx_block_quote_token.remove_last_bleading_space()
assert (
last_leading_space[0] == "\n"
), "Removed leading space must start with \\n."
last_leading_space = last_leading_space[1:]
_ = xx_block_quote_token.remove_last_bleading_space()
# assert (
# last_leading_space[0] == "\n"
# ), "Removed leading space must start with \\n."
# last_leading_space = last_leading_space[1:]

POGGER.debug(
"__adjust_for_list_container_after_block_quote_special_special>>block_token>>$",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ def __xx_multiple_fix_leading_spaces(
for _ in link_def_token.continuation_lines:
last_leading_space = block_quote_token.remove_last_bleading_space()
POGGER.debug("last_leading_space>:$:<", last_leading_space)
if last_leading_space[0] == "\n":
last_leading_space = last_leading_space[1:]
# if last_leading_space[0] == "\n":
# last_leading_space = last_leading_space[1:]
leading_spaces.append(last_leading_space)
assert len(split_tabs_list) == len(
leading_spaces
Expand Down
2 changes: 1 addition & 1 deletion pymarkdown/list_blocks/list_block_pre_list_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def __handle_list_nesting_all_conditionals(
current_last_block_token,
)
current_last_block_token.add_bleading_spaces(
removed_leading_spaces, skip_adding_newline=True
removed_leading_spaces, skip_adding_newline=False
)
POGGER.debug(
"__handle_list_nesting_all_conditionals>>block_token>>$",
Expand Down
3 changes: 2 additions & 1 deletion pymarkdown/tokens/block_quote_markdown_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(
self.weird_kludge_four: Optional[Tuple[int, int, int, str]] = None
self.weird_kludge_five = False
self.weird_kludge_six = False
self.weird_kludge_seven = False

# pylint: disable=protected-access
@staticmethod
Expand Down Expand Up @@ -135,7 +136,7 @@ def remove_last_bleading_space(self) -> str:
self.__leading_spaces = ""
self.weird_kludge_five = False
else:
extracted_text = self.__leading_spaces[last_separator_index:]
extracted_text = self.__leading_spaces[last_separator_index + 1 :]
self.__leading_spaces = self.__leading_spaces[:last_separator_index]
self.leading_text_index -= 1
self.__compose_extra_data_field()
Expand Down
11 changes: 6 additions & 5 deletions pymarkdown/transform_markdown/transform_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,11 @@ def __adjust_state_for_element_inner_block_quote(
).weird_kludge_three
and container_token_indices[current_block_quote_token_index] == 1
):
container_token_indices[previous_block_quote_token_index] += 1
previous_block_quote_token = cast(
BlockQuoteMarkdownToken, token_stack[previous_block_quote_token_index]
)
if not previous_block_quote_token.weird_kludge_seven:
container_token_indices[previous_block_quote_token_index] += 1
elif (
previous_block_quote_token_index >= 0
and container_token_indices[current_block_quote_token_index] == 1
Expand Down Expand Up @@ -1398,7 +1402,6 @@ def __adjust_for_list_end_part_2(
POGGER.debug(
f"inner_token_index={inner_token_index} < len(split)={len(split_leading_spaces)}"
)
# following assert was if to return
assert inner_token_index < len(split_leading_spaces)
POGGER.debug(
f" adj-->container_line>:{ParserHelper.make_value_visible(container_line)}:<"
Expand Down Expand Up @@ -1994,9 +1997,7 @@ def __adjust(
)
split_leading_spaces = leading_spaces.split(ParserHelper.newline_character)
inner_token_index = container_token_indices[nested_list_start_index]
assert inner_token_index < len(
split_leading_spaces
), "Index must be within the string."
assert inner_token_index < len(split_leading_spaces)
POGGER.debug(
f"inner_index->{str(container_token_indices[nested_list_start_index])}"
)
Expand Down
Loading

0 comments on commit 8f9eea1

Please sign in to comment.