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 1616# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1717# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1818
19+ import re
1920from typing import List
2021from uuid import uuid4
2122
2223from markdown_it import MarkdownIt
2324from markdown_it .token import Token
2425
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+
2531
2632def tasklists_plugin (
2733 md : MarkdownIt ,
@@ -144,8 +150,4 @@ def is_list_item(token):
144150
145151 def starts_with_todo_markdown (token ):
146152 # 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:
107107</ol >
108108
109109.
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