File tree Expand file tree Collapse file tree 2 files changed +29
-5
lines changed
mdit_py_plugins/tasklists Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Original file line number Diff line number Diff line change 16
16
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
17
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
18
19
+ import re
19
20
from typing import List
20
21
from uuid import uuid4
21
22
22
23
from markdown_it import MarkdownIt
23
24
from markdown_it .token import Token
24
25
26
+ # Regex string to match a whitespace character, as specified in
27
+ # https://github.github.com/gfm/#whitespace-character
28
+ # (spec version 0.29-gfm (2019-04-06))
29
+ _GFM_WHITESPACE_RE = r"[ \t\n\v\f\r]"
30
+
25
31
26
32
def tasklists_plugin (
27
33
md : MarkdownIt ,
@@ -144,8 +150,4 @@ def is_list_item(token):
144
150
145
151
def starts_with_todo_markdown (token ):
146
152
# leading whitespace in a list item is already trimmed off by markdown-it
147
- return (
148
- token .content .startswith ("[ ] " )
149
- or token .content .startswith ("[x] " )
150
- or token .content .startswith ("[X] " )
151
- )
153
+ return re .match (rf"\[[ xX]]{ _GFM_WHITESPACE_RE } +" , token .content )
Original file line number Diff line number Diff line change @@ -107,3 +107,25 @@ oedered.md:
107
107
</ol >
108
108
109
109
.
110
+
111
+ Tab after task list item marker
112
+ .
113
+ + [x] item 1
114
+ + [ ] item 2
115
+ .
116
+ <ul class =" contains-task-list " >
117
+ <li class =" task-list-item " > item 1</li >
118
+ <li class =" task-list-item " > item 2</li >
119
+ </ul >
120
+ .
121
+
122
+ Form feed after task list item marker
123
+ .
124
+ + [ x] item 1
125
+ + [ ] item 2
126
+ .
127
+ <ul class =" contains-task-list " >
128
+ <li class =" task-list-item " >item 1</li >
129
+ <li class =" task-list-item " >item 2</li >
130
+ </ul >
131
+ .
You can’t perform that action at this time.
0 commit comments