Skip to content

Commit 87c0139

Browse files
NightFlyerAshe Connor
authored andcommitted
Fix bug with determining if task is complete & adjust to spec. (commonmark#142)
* Had incorrect check for whether opaque data meant that the task was complete * The spec says that either an upper or lower case X means the task is complete.
1 parent b8eb2e0 commit 87c0139

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

extensions/tasklist.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ char *cmark_gfm_extensions_get_tasklist_state(cmark_node *node) {
1717
if (!node || ((int)node->as.opaque != CMARK_TASKLIST_CHECKED && (int)node->as.opaque != CMARK_TASKLIST_NOCHECKED))
1818
return 0;
1919

20-
if ((int)node->as.opaque != CMARK_TASKLIST_CHECKED) {
20+
if ((int)node->as.opaque == CMARK_TASKLIST_CHECKED) {
2121
return "checked";
2222
}
2323
else {
@@ -74,7 +74,8 @@ static cmark_node *open_tasklist_item(cmark_syntax_extension *self,
7474
cmark_node_set_syntax_extension(parent_container, self);
7575
cmark_parser_advance_offset(parser, (char *)input, 3, false);
7676

77-
if (strstr((char*)input, "[x]")) {
77+
// Either an upper or lower case X means the task is completed.
78+
if (strstr((char*)input, "[x]") || strstr((char*)input, "[X]")) {
7879
parent_container->as.opaque = (void *)CMARK_TASKLIST_CHECKED;
7980
} else {
8081
parent_container->as.opaque = (void *)CMARK_TASKLIST_NOCHECKED;

0 commit comments

Comments
 (0)