Skip to content

Commit

Permalink
https://github.com/jackdewinter/pymarkdown/issues/1103
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdewinter committed Jun 8, 2024
1 parent b23ab2e commit e473274
Show file tree
Hide file tree
Showing 56 changed files with 1,042 additions and 2,495 deletions.
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": 4831,
"totalCovered": 4831
"totalMeasured": 4853,
"totalCovered": 4853
},
"lineLevel": {
"totalMeasured": 19406,
"totalCovered": 19406
"totalMeasured": 19465,
"totalCovered": 19465
}
}

6 changes: 2 additions & 4 deletions publish/pylint_suppression.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,7 @@
},
"pymarkdown/plugins/rule_md_035.py": {},
"pymarkdown/plugins/rule_md_036.py": {},
"pymarkdown/plugins/rule_md_037.py": {
"too-many-arguments": 1
},
"pymarkdown/plugins/rule_md_037.py": {},
"pymarkdown/plugins/rule_md_038.py": {},
"pymarkdown/plugins/rule_md_039.py": {},
"pymarkdown/plugins/rule_md_040.py": {},
Expand Down Expand Up @@ -499,7 +497,7 @@
"too-many-instance-attributes": 24,
"too-many-public-methods": 4,
"too-few-public-methods": 39,
"too-many-arguments": 227,
"too-many-arguments": 226,
"too-many-locals": 38,
"chained-comparison": 1,
"too-many-boolean-expressions": 2,
Expand Down
4 changes: 2 additions & 2 deletions publish/test-results.json
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@
},
{
"name": "test.rules.test_md037",
"totalTests": 42,
"totalTests": 56,
"failedTests": 0,
"errorTests": 0,
"skippedTests": 0,
Expand Down Expand Up @@ -1620,7 +1620,7 @@
},
{
"name": "test.test_markdown_extra",
"totalTests": 146,
"totalTests": 148,
"failedTests": 0,
"errorTests": 0,
"skippedTests": 0,
Expand Down
19 changes: 14 additions & 5 deletions pymarkdown/coalesce/coalesce_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CoalesceProcessor:

@staticmethod
def coalesce_text_blocks(
first_pass_results: List[MarkdownToken],
first_pass_results: List[MarkdownToken], only_change_text_blocks: bool = False
) -> List[MarkdownToken]:
"""
Take a pass and combine any two adjacent text blocks into one.
Expand All @@ -41,9 +41,12 @@ def coalesce_text_blocks(
if coalesced_list[-1].is_text:
# POGGER.debug("__coalesce_with_previous")
did_process = CoalesceProcessor.__coalesce_with_previous(
first_pass_results, coalesced_list, coalesce_index
first_pass_results,
coalesced_list,
coalesce_index,
only_change_text_blocks,
)
else:
elif not only_change_text_blocks:
did_process = (
first_pass_results[coalesce_index].is_blank_line
and coalesced_list[-1].is_code_block
Expand All @@ -53,12 +56,15 @@ def coalesce_text_blocks(
CoalesceProcessor.__coalesce_with_blank_line(
first_pass_results, coalesced_list, coalesce_index
)
else:
did_process = False
if not did_process:
coalesced_list.append(first_pass_results[coalesce_index])
# POGGER.debug("coalesced_list:$:", coalesced_list)

# POGGER.debug("--Final--coalesced_list:$:", coalesced_list)
CoalesceProcessor.__calculate_final_whitespaces(coalesced_list)
if not only_change_text_blocks:
CoalesceProcessor.__calculate_final_whitespaces(coalesced_list)
# POGGER.debug("coalesced_list:$:", coalesced_list)

return coalesced_list
Expand Down Expand Up @@ -96,6 +102,7 @@ def __coalesce_with_previous(
first_pass_results: List[MarkdownToken],
coalesced_list: List[MarkdownToken],
coalesce_index: int,
only_change_text_blocks: bool,
) -> bool:
# POGGER.debug(">>coalesce_text_blocks>>>>$<<", coalesced_list[-1])
if not first_pass_results[coalesce_index].is_text and (
Expand All @@ -121,7 +128,9 @@ def __coalesce_with_previous(
# POGGER.debug("combine1>>$", text_token)
# POGGER.debug("combine2>>$", first_pass_results[coalesce_index])
indented_whitespace = text_token.combine(
first_pass_results[coalesce_index], remove_leading_spaces
first_pass_results[coalesce_index],
remove_leading_spaces,
only_change_text_blocks,
)
# POGGER.debug("combined>>$", text_token)
# POGGER.debug("indented_whitespace>>$<<", indented_whitespace)
Expand Down
5 changes: 4 additions & 1 deletion pymarkdown/general/tokenized_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,11 @@ def __transform(self, do_add_end_of_stream_token: bool) -> List[MarkdownToken]:
coalesced_results, self.__parse_properties
)

final_coalesced_results = CoalesceProcessor.coalesce_text_blocks(
final_pass_results, only_change_text_blocks=True
)
POGGER.debug("\n\n>>>>>>>final_pass_results>>>>>>")
return final_pass_results
return final_coalesced_results
except Exception as this_exception:
raise BadTokenizationError(
"An unhandled error occurred processing the document."
Expand Down
Loading

0 comments on commit e473274

Please sign in to comment.