Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 838 #880

Merged
merged 2 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
black = "==23.10.0"
black = "==23.11.0"
coverage = "==7.3.2"
isort = "==5.12.0"
flake8 = "==6.1.0"
flake8-bugbear = "==23.9.16"
flake8-bandit = "==4.1.1"
mypy = "==1.6.1"
mypy = "==1.7.1"
pdoc3 = "==0.10.0"
pre-commit = "==3.5.0"
project-summarizer = "==0.5.0"
Expand All @@ -22,11 +22,11 @@ pytest = "==7.4.3"
pytest-cov = "==4.1.0"
pytest-console-scripts = "==1.4.1"
pytest-timeout = "==2.2.0"
pytest-html = "==3.1.1"
pytest-xdist = "==3.3.1"
pytest-html = "==4.1.1"
pytest-xdist = "==3.5.0"
setuptools = "==68.2.2"
snakeviz = "==2.2.0"
sourcery = "==1.13.0"
sourcery = "==1.14.0"
twine = "==4.0.2"
types-pyyaml = "*"

Expand Down
234 changes: 121 additions & 113 deletions Pipfile.lock

Large diffs are not rendered by default.

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": 4237,
"totalCovered": 4237
"totalMeasured": 4239,
"totalCovered": 4239
},
"lineLevel": {
"totalMeasured": 17788,
"totalCovered": 17788
"totalMeasured": 17798,
"totalCovered": 17798
}
}

8 changes: 4 additions & 4 deletions publish/test-results.json
Original file line number Diff line number Diff line change
Expand Up @@ -711,15 +711,15 @@
"totalTests": 73,
"failedTests": 0,
"errorTests": 0,
"skippedTests": 1,
"skippedTests": 0,
"elapsedTimeInMilliseconds": 0
},
{
"name": "test.gfm.test_markdown_whitespace_indented",
"totalTests": 63,
"failedTests": 0,
"errorTests": 0,
"skippedTests": 2,
"skippedTests": 0,
"elapsedTimeInMilliseconds": 0
},
{
Expand All @@ -740,10 +740,10 @@
},
{
"name": "test.gfm.test_markdown_whitespace_paragraph",
"totalTests": 56,
"totalTests": 58,
"failedTests": 0,
"errorTests": 0,
"skippedTests": 0,
"skippedTests": 1,
"elapsedTimeInMilliseconds": 0
},
{
Expand Down
36 changes: 27 additions & 9 deletions pymarkdown/leaf_blocks/indented_leaf_block_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,27 @@ def __parse_indented_code_block_with_tab_list_list(
POGGER.debug("lead_space_len>:$:<", lead_space_len)
return last_list_token, last_list_lead_spaces, lead_space_len

@staticmethod
def __find_string(
fex_space: str, fex_space_index: int, lead_space_len: int
) -> Tuple[Optional[str], int]:
keep_going = True
search_index = 1
ex_part = None
while keep_going:
ex_part = fex_space[:search_index]
# TODO see if this is a pattern
# __adjust_block_quote_indent_for_tab_list_kludge
# search_for_tabbed_prefix
detabbed_ex_part = TabHelper.detabify_string(ex_part, fex_space_index)
keep_going = (
len(detabbed_ex_part) < len(fex_space)
and len(detabbed_ex_part) < lead_space_len
)
if keep_going:
search_index += 1
return ex_part, search_index

# pylint: disable=too-many-locals
@staticmethod
def __parse_indented_code_block_with_tab_list(
Expand All @@ -171,7 +192,7 @@ def __parse_indented_code_block_with_tab_list(
fex_space, fex_space_index, split_tab = TabHelper.find_tabified_string(
original_line,
position_marker.text_to_parse,
use_proper_traverse=True,
use_proper_traverse=False,
reconstruct_prefix=last_list_lead_spaces,
was_indented=was_indented,
)
Expand All @@ -180,15 +201,12 @@ def __parse_indented_code_block_with_tab_list(
extra_index = 0
if split_tab:
extra_index = lead_space_len
while (
indent_used < len(last_list_lead_spaces)
and fex_space[indent_used] != "\t"
):
indent_used += 1
else:
detab_fex_space = TabHelper.detabify_string(fex_space, fex_space_index)
assert detab_fex_space == position_marker.text_to_parse
ex_part, search_index = IndentedLeafBlockProcessor.__find_string(
fex_space, fex_space_index, lead_space_len
)
indent_used = search_index - 1

# TODO __find_string?
keep_going = True
search_index = 1
while keep_going:
Expand Down
1 change: 0 additions & 1 deletion test/gfm/test_markdown_whitespace_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,6 @@ def test_whitespaces_html_with_tabs_before_within_ordered_double_list_tab_after_


@pytest.mark.gfm
@pytest.mark.skip
def test_whitespaces_html_with_tabs_before_within_ordered_double_list_one_space():
"""
Test case: Html blocks preceeded by spaces and tabs.
Expand Down
22 changes: 14 additions & 8 deletions test/gfm/test_markdown_whitespace_indented.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,6 @@ def test_whitespaces_indented_code_with_tabs_before_within_unordered_double_list
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.skip
@pytest.mark.gfm
def test_whitespaces_indented_code_with_tabs_before_within_unordered_double_list_with_blank_line():
"""
Expand All @@ -602,7 +601,7 @@ def test_whitespaces_indented_code_with_tabs_before_within_unordered_double_list
"[end-para:::True]",
"[BLANK(3,1):]",
"[icode-block(4,9):\t:]",
"[text(4,9):\tghi:]",
"[text(4,9):ghi:]",
"[end-icode-block:::True]",
"[end-ulist:::True]",
"[end-ulist:::True]",
Expand Down Expand Up @@ -855,7 +854,6 @@ def test_whitespaces_indented_code_with_tabs_before_within_ordered_list_and_spac
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.skip
@pytest.mark.gfm
def test_whitespaces_indented_code_with_tabs_before_within_ordered_double_list_x():
"""
Expand All @@ -865,24 +863,32 @@ def test_whitespaces_indented_code_with_tabs_before_within_ordered_double_list_x
# Arrange
source_markdown = """1. abc
1. def

\t\t ghi"""
expected_tokens = [
"[olist(1,1):.:1:3:]",
"[para(1,4):]",
"[text(1,4):abc:]",
"[end-para:::True]",
"[olist(2,4):.:1:6: :]",
"[para(2,7):\n\t ]",
"[text(2,7):def\nghi::\n]",
"[olist(2,4):.:1:6: :\n\t]",
"[para(2,7):]",
"[text(2,7):def:]",
"[end-para:::True]",
"[BLANK(3,1):]",
"[icode-block(4,11):\t :]",
"[text(4,11):ghi:]",
"[end-icode-block:::True]",
"[end-olist:::True]",
"[end-olist:::True]",
]
expected_gfm = """<ol>
<li>abc
<ol>
<li>def
ghi</li>
<li>
<p>def</p>
<pre><code>ghi
</code></pre>
</li>
</ol>
</li>
</ol>"""
Expand Down
72 changes: 72 additions & 0 deletions test/gfm/test_markdown_whitespace_paragraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,41 @@ def test_whitespaces_paragraph_with_tabs_before_within_unordered_double_list():
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.gfm
def test_whitespaces_paragraph_with_tabs_before_within_unordered_double_list_double_tabs():
"""
Test case: TBD
"""

# Arrange
source_markdown = """+ abc
+ def
\t\tghi"""
expected_tokens = [
"[ulist(1,1):+::2:]",
"[para(1,3):]",
"[text(1,3):abc:]",
"[end-para:::True]",
"[ulist(2,3):+::4: :\t]",
"[para(2,5):\n\t]",
"[text(2,5):def\nghi::\n]",
"[end-para:::True]",
"[end-ulist:::True]",
"[end-ulist:::True]",
]
expected_gfm = """<ul>
<li>abc
<ul>
<li>def
ghi</li>
</ul>
</li>
</ul>"""

# Act & Assert
act_and_assert(source_markdown, expected_gfm, expected_tokens, show_debug=False)


@pytest.mark.gfm
def test_whitespaces_paragraph_with_tabs_before_within_ordered_list_x():
"""
Expand Down Expand Up @@ -468,6 +503,43 @@ def test_whitespaces_paragraph_with_tabs_before_within_ordered_double_list_x():
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.gfm
@pytest.mark.skip
def test_whitespaces_paragraph_with_tabs_before_within_ordered_double_list_double_tabs():
"""
Test case: This was intended to be an indented block, but is not due to a
paragraph continutation
"""

# Arrange
source_markdown = """1. abc
1. def
\t\t ghi"""
expected_tokens = [
"[olist(1,1):.:1:3:]",
"[para(1,4):]",
"[text(1,4):abc:]",
"[end-para:::True]",
"[olist(2,4):.:1:6: :]",
"[para(2,7):\n\t ]",
"[text(2,7):def\nghi::\n]",
"[end-para:::True]",
"[end-olist:::True]",
"[end-olist:::True]",
]
expected_gfm = """<ol>
<li>abc
<ol>
<li>def
ghi</li>
</ol>
</li>
</ol>"""

# Act & Assert
act_and_assert(source_markdown, expected_gfm, expected_tokens, show_debug=False)


@pytest.mark.gfm
def test_whitespaces_paragraph_with_tabs_before_within_ordered_double_list_no_spaces():
"""
Expand Down
Loading