Skip to content

Commit

Permalink
Document GFM whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkin committed Mar 2, 2022
1 parent 2cc89e4 commit edec998
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mdit_py_plugins/tasklists/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
from markdown_it import MarkdownIt
from markdown_it.token import Token

# Regex string to match a whitespace character, as specified in
# https://github.github.com/gfm/#whitespace-character
# (spec version 0.29-gfm (2019-04-06))
_GFM_WHITESPACE_RE = r"[ \t\n\v\f\r]"


def tasklists_plugin(
md: MarkdownIt,
Expand Down Expand Up @@ -145,4 +150,4 @@ def is_list_item(token):

def starts_with_todo_markdown(token):
# leading whitespace in a list item is already trimmed off by markdown-it
return re.match(r"\[[ xX]][ \t\n\v\f\r]+", token.content)
return re.match(rf"\[[ xX]]{_GFM_WHITESPACE_RE}+", token.content)

0 comments on commit edec998

Please sign in to comment.