Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdewinter authored Dec 8, 2024
1 parent 72523ad commit f6c9f66
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ setuptools = "==75.3.0"
snakeviz = "==2.2.0"
sourcery = "==1.24.0"
types-pyyaml = "*"
twine = "<5.1"

[packages]
columnar = ">=1.4.0"
application-properties = ">=0.8.2"
typing-extensions = ">=4.7.0"
twine = "<5.1"

[requires]
python_version = "3.8"
Expand Down
5 changes: 4 additions & 1 deletion newdocs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
- [Issue 1274](https://github.com/jackdewinter/pymarkdown/issues/1274)
- Fixed remaining assert issues, leaving fixes that produce valid
Markdown, but not the intended Markdown.
- [Issue 1267](https://github.com/jackdewinter/pymarkdown/issues/1267)
- Fixed reported issue with task lists creating an error in Md018.

<!--- pyml disable-next-line no-duplicate-heading-->
### Changed

None
- [Issue 1258](https://github.com/jackdewinter/pymarkdown/issues/1258)
- Moved twine package into dev section

## Version 0.9.25 - Date: 2024-11-07

Expand Down
4 changes: 2 additions & 2 deletions publish/coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"totalCovered": 5503
},
"lineLevel": {
"totalMeasured": 21389,
"totalCovered": 21389
"totalMeasured": 21393,
"totalCovered": 21393
}
}

2 changes: 1 addition & 1 deletion publish/test-results.json
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@
},
{
"name": "test.rules.test_md018",
"totalTests": 29,
"totalTests": 30,
"failedTests": 0,
"errorTests": 0,
"skippedTests": 0,
Expand Down
1 change: 1 addition & 0 deletions pymarkdown/plugins/rule_md_018.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def __next_token_paragraph_non_text_inline(self, token: MarkdownToken) -> None:
token.is_inline_emphasis
or token.is_inline_emphasis_end
or token.is_inline_autolink
or token.is_task_list
)
self.__delayed_line = None

Expand Down
23 changes: 16 additions & 7 deletions pymarkdown/tokens/markdown_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,18 @@ class MarkdownToken:
extra_data_separator = ":"

_end_token_prefix = "end-"

_token_pragma = "pragma"
_token_task_list = "task-list"
_token_end_of_stream = "end-of-stream"

_token_task_list = "task-list"
_token_front_matter = "front-matter"

_token_block_quote = "block-quote"
_token_unordered_list_start = "ulist"
_token_ordered_list_start = "olist"
_token_new_list_item = "li"

_token_paragraph = "para"
_token_blank_line = "BLANK"
_token_atx_heading = "atx"
Expand All @@ -46,13 +54,7 @@ class MarkdownToken:
_token_html_block = "html-block"
_token_fenced_code_block = "fcode-block"
_token_indented_code_block = "icode-block"
_token_block_quote = "block-quote"
_token_text = "text"
_token_front_matter = "front-matter"

_token_unordered_list_start = "ulist"
_token_ordered_list_start = "olist"
_token_new_list_item = "li"

_token_inline_code_span = "icode-span"
_token_inline_hard_break = "hard-break"
Expand Down Expand Up @@ -380,6 +382,13 @@ def is_front_matter(self) -> bool:
"""
return self.token_name == MarkdownToken._token_front_matter

@property
def is_task_list(self) -> bool:
"""
Returns whether the current token is the task list element.
"""
return self.token_name == MarkdownToken._token_task_list

@property
def is_text(self) -> bool:
"""
Expand Down
43 changes: 43 additions & 0 deletions test/rules/test_md018.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
from test.markdown_scanner import MarkdownScanner
from test.rules.utils import execute_query_configuration_test, pluginQueryConfigTest
from test.utils import create_temporary_configuration_file

import pytest

Expand Down Expand Up @@ -1044,6 +1045,48 @@ def test_md018_bad_single_paragraph_with_whitespace():
)


@pytest.mark.rules
def test_md018_issue_1267():
"""
Test to make sure this rule handles having a task list as part of the document.
Reported as Issue 1267, ran up against guard code.
"""

# Arrange
scanner = MarkdownScanner()
source_file_contents = """---
title: abc
---
- [ ] abc
"""

with create_temporary_configuration_file(
source_file_contents, file_name_suffix=".md"
) as source_path:
supplied_arguments = [
"--disable-rules",
"md022",
"--set",
"extensions.markdown-task-list-items.enabled=$!True",
"--stack-trace",
"scan",
source_path,
]

expected_return_code = 0
expected_output = ""
expected_error = ""

# Act
execute_results = scanner.invoke_main(arguments=supplied_arguments)

# Assert
execute_results.assert_results(
expected_output, expected_error, expected_return_code
)


def test_md018_query_config():
config_test = pluginQueryConfigTest(
"md018",
Expand Down

0 comments on commit f6c9f66

Please sign in to comment.