Skip to content

Commit

Permalink
Merge pull request #16 from gillchristian/feature/add-task-list-support
Browse files Browse the repository at this point in the history
feat(extensions): Add support for task list extension
  • Loading branch information
Ashe Connor authored Nov 15, 2019
2 parents 3f42630 + 0a11435 commit 3bd7966
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMarkGFM.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module CMarkGFM (
, extTable
, extAutolink
, extTagfilter
, extTaskList
, Node(..)
, NodeType(..)
, PosInfo(..)
Expand Down Expand Up @@ -302,6 +303,9 @@ extAutolink = CMarkExtension "autolink"
extTagfilter :: CMarkExtension
extTagfilter = CMarkExtension "tagfilter"

extTaskList :: CMarkExtension
extTaskList = CMarkExtension "tasklist"

ptrToNodeType :: NodePtr -> IO NodeType
ptrToNodeType ptr = do
nodeType <- c_cmark_node_get_type ptr
Expand Down
15 changes: 15 additions & 0 deletions bench/full-sample.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,21 @@ of a list item

- - - - - - - - - deeply-nested one-element item

- [ ] a task list
- [x] a check item in the task list

- [ ] loose task list item

- [x] loose checked task list item

- [ ] nested items in the task list
- [ ] nested item 1
- [x] checked nested item 2
- [ ] must go deeper
- [x] checked deeper nested item 2
- [ ] must go even deeper
- [x] checked even deeper nested item 2

[1] [2] [3] [1] [2] [3]

[looooooooooooooooooooooooooooooooooooooooooooooooooong label]
Expand Down
2 changes: 2 additions & 0 deletions test/test-cmark.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ tests = TestList [
, Node (Just (PosInfo {startLine = 1, startColumn = 1, endLine = 3, endColumn = 17})) DOCUMENT [Node (Just (PosInfo {startLine = 1, startColumn = 1, endLine = 3, endColumn = 17})) (TABLE [LeftAligned,CenterAligned,NoAlignment,RightAligned]) [Node (Just (PosInfo {startLine = 1, startColumn = 1, endLine = 1, endColumn = 17})) TABLE_ROW [Node (Just (PosInfo {startLine = 1, startColumn = 2, endLine = 1, endColumn = 4})) TABLE_CELL [Node (Just (PosInfo {startLine = 1, startColumn = 3, endLine = 1, endColumn = 3})) (TEXT "a") []],Node (Just (PosInfo {startLine = 1, startColumn = 6, endLine = 1, endColumn = 8})) TABLE_CELL [Node (Just (PosInfo {startLine = 1, startColumn = 7, endLine = 1, endColumn = 7})) (TEXT "b") []],Node (Just (PosInfo {startLine = 1, startColumn = 10, endLine = 1, endColumn = 12})) TABLE_CELL [Node (Just (PosInfo {startLine = 1, startColumn = 11, endLine = 1, endColumn = 11})) (TEXT "c") []],Node (Just (PosInfo {startLine = 1, startColumn = 14, endLine = 1, endColumn = 16})) TABLE_CELL [Node (Just (PosInfo {startLine = 1, startColumn = 15, endLine = 1, endColumn = 15})) (TEXT "d") []]],Node (Just (PosInfo {startLine = 3, startColumn = 1, endLine = 3, endColumn = 17})) TABLE_ROW [Node (Just (PosInfo {startLine = 3, startColumn = 2, endLine = 3, endColumn = 4})) TABLE_CELL [Node (Just (PosInfo {startLine = 3, startColumn = 3, endLine = 3, endColumn = 3})) (TEXT "y") []],Node (Just (PosInfo {startLine = 3, startColumn = 6, endLine = 3, endColumn = 8})) TABLE_CELL [Node (Just (PosInfo {startLine = 3, startColumn = 7, endLine = 3, endColumn = 7})) (TEXT "o") []],Node (Just (PosInfo {startLine = 3, startColumn = 10, endLine = 3, endColumn = 12})) TABLE_CELL [Node (Just (PosInfo {startLine = 3, startColumn = 11, endLine = 3, endColumn = 11})) (TEXT "s") []],Node (Just (PosInfo {startLine = 3, startColumn = 14, endLine = 3, endColumn = 16})) TABLE_CELL [Node (Just (PosInfo {startLine = 3, startColumn = 15, endLine = 3, endColumn = 15})) (TEXT "h") []]]]] ~=? commonmarkToNode [] [extTable] "| a | b | c | d |\n| :-- | :-: | --- | --: |\n| y | o | s | h |"
, "<xmp>\n" ~=? commonmarkToHtml [optUnsafe] [] "<xmp>"
, "&lt;xmp>\n" ~=? commonmarkToHtml [optUnsafe] [extTagfilter] "<xmp>"
, "<ul>\n<li><input type=\"checkbox\" disabled=\"\" /> foo</li>\n<li><input type=\"checkbox\" checked=\"\" disabled=\"\" /> bar</li>\n</ul>\n" ~=? commonmarkToHtml [] [extTaskList] "- [ ] foo\n- [x] bar"
]

0 comments on commit 3bd7966

Please sign in to comment.