diff --git a/mdit_py_plugins/tasklists/__init__.py b/mdit_py_plugins/tasklists/__init__.py index 089bb5d..81a9bd4 100644 --- a/mdit_py_plugins/tasklists/__init__.py +++ b/mdit_py_plugins/tasklists/__init__.py @@ -108,12 +108,14 @@ def todoify(token: Token) -> None: def make_checkbox(token: Token) -> Token: checkbox = Token("html_inline", "", 0) disabled_attr = 'disabled="disabled"' if disable_checkboxes else "" - if token.content.startswith("[ ] "): + # starts_with_todo_markdown already matched "[ ]", "[x]" or "[X]" followed by + # any GFM whitespace, so only the character inside the brackets matters here + if token.content[1] == " ": checkbox.content = ( '' ) - elif token.content.startswith("[x] ") or token.content.startswith("[X] "): + else: checkbox.content = ( '' diff --git a/tests/fixtures/tasklists.md b/tests/fixtures/tasklists.md index dec0fef..9b209f2 100644 --- a/tests/fixtures/tasklists.md +++ b/tests/fixtures/tasklists.md @@ -114,8 +114,8 @@ Tab after task list item marker + [ ] item 2 .