Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions commonmark-extensions/src/Commonmark/Extensions/TaskList.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@ taskListItemBlockSpec = BlockSpec
listItemType lidata
-> addNodeToStack linode
_ -> addNodeToStack listnode >> addNodeToStack linode
blankAfterMarker <- optionMaybe blankLine
pos' <- getPosition
case blankAfterMarker of
Just _ -> return ()
Nothing -> do
toks <- many (satisfyTok (not . hasType LineEnd))
addNodeToStack $
Node (defBlockData paraSpec){
blockStartPos = [pos']
, blockLines = [toks] }
[]
Comment on lines +142 to +146
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if there are no tokens after the marker, or only spaces? Do we get an empty Para? Should that be avoided?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be an empty para here. This code is part of a case statement that checks for that.

return BlockStartMatch
, blockCanContain = const True
, blockContainsLines = False
Expand Down Expand Up @@ -184,11 +195,11 @@ itemStart = do
pos <- getPosition
ty <- bulletListMarker
aftercol <- sourceColumn <$> getPosition
checked <- parseCheckbox
lookAhead whitespace
numspaces <- try (gobbleUpToSpaces 4 <* notFollowedBy whitespace)
<|> gobbleSpaces 1
<|> 1 <$ lookAhead lineEnd
checked <- parseCheckbox
lookAhead whitespace
return $! (pos, ListItemData{
listItemType = ty
, listItemChecked = checked
Expand Down
63 changes: 63 additions & 0 deletions commonmark-extensions/test/task_lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,66 @@ As in GitHub-flavored Markdown.
</ul>
````````````````````````````````


```````````````````````````````` example
- [x]unreal
.
<ul>
<li>[x]unreal</li>
</ul>
````````````````````````````````


```````````````````````````````` example
- [x] real

not indented enough
.
<ul class="task-list">
<li><input type="checkbox" disabled="" checked="" />real</li>
</ul>
<p>not indented enough</p>
````````````````````````````````


```````````````````````````````` example
- [x] * some text
- [ ] > some text
- [x]
* some text
- [ ]
> some text
.
<ul class="task-list">
<li><input type="checkbox" disabled="" checked="" />* some text</li>
<li><input type="checkbox" disabled="" />&gt; some text</li>
<li><input type="checkbox" disabled="" checked="" /><ul>
<li>some text</li>
</ul></li>
<li><input type="checkbox" disabled="" /><blockquote>
<p>some text</p>
</blockquote></li>
</ul>
````````````````````````````````

There is no empty paragraph after the `]`.

```````````````````````````````` example
- [x] * some text

- [x]

some text

- [x]→

some text
.
<ul class="task-list">
<li><input type="checkbox" disabled="" checked="" /><p>* some text</p></li>
<li><input type="checkbox" disabled="" checked="" /><p>some text</p>
</li>
<li><input type="checkbox" disabled="" checked="" /><p>some text</p>
</li>
</ul>
````````````````````````````````
Loading