Skip to content

Commit

Permalink
Merge pull request KristopherGBaker#6 from KristopherGBaker/tasklist-…
Browse files Browse the repository at this point in the history
…update

Update tasklist.c with recent changes from cmark-gfm
  • Loading branch information
KristopherGBaker authored May 7, 2019
2 parents 9d64924 + cfabbfa commit 24629a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion Sources/libcmark_gfm/tasklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static cmark_node *open_tasklist_item(cmark_syntax_extension *self,
cmark_node_set_syntax_extension(parent_container, self);
cmark_parser_advance_offset(parser, (char *)input, 3, false);

// Spec says that either upper or lower case x means completed.
// Either an upper or lower case X means the task is completed.
if (strstr((char*)input, "[x]") || strstr((char*)input, "[X]")) {
parent_container->as.opaque = (void *)CMARK_TASKLIST_CHECKED;
} else {
Expand Down Expand Up @@ -121,6 +121,15 @@ static void html_render(cmark_syntax_extension *extension,
}
}

static const char *xml_attr(cmark_syntax_extension *extension,
cmark_node *node) {
if ((int)node->as.opaque == CMARK_TASKLIST_CHECKED) {
return " completed=\"true\"";
} else {
return " completed=\"false\"";
}
}

cmark_syntax_extension *create_tasklist_extension(void) {
cmark_syntax_extension *ext = cmark_syntax_extension_new("tasklist");

Expand All @@ -131,6 +140,7 @@ cmark_syntax_extension *create_tasklist_extension(void) {
cmark_syntax_extension_set_commonmark_render_func(ext, commonmark_render);
cmark_syntax_extension_set_plaintext_render_func(ext, commonmark_render);
cmark_syntax_extension_set_html_render_func(ext, html_render);
cmark_syntax_extension_set_xml_attr_func(ext, xml_attr);

return ext;
}
2 changes: 1 addition & 1 deletion libcmark_gfm.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "libcmark_gfm"
s.version = "0.29.0"
s.version = "0.29.1"
s.summary = "Swift compatible framework for cmark-gfm"

s.description = <<-DESC
Expand Down

0 comments on commit 24629a5

Please sign in to comment.