Skip to content

Commit 4a7985e

Browse files
NightFlyerAshe Connor
authored andcommitted
Add XML attribute to tasklist (commonmark#145)
I'm not positive this is the best attribute to use, but at least it doesn't lose the information as to whether the task was completed.
1 parent 87c0139 commit 4a7985e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

extensions/tasklist.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ static void html_render(cmark_syntax_extension *extension,
121121
}
122122
}
123123

124+
static const char *xml_attr(cmark_syntax_extension *extension,
125+
cmark_node *node) {
126+
if ((int)node->as.opaque == CMARK_TASKLIST_CHECKED) {
127+
return " completed=\"true\"";
128+
} else {
129+
return " completed=\"false\"";
130+
}
131+
}
132+
124133
cmark_syntax_extension *create_tasklist_extension(void) {
125134
cmark_syntax_extension *ext = cmark_syntax_extension_new("tasklist");
126135

@@ -131,6 +140,7 @@ cmark_syntax_extension *create_tasklist_extension(void) {
131140
cmark_syntax_extension_set_commonmark_render_func(ext, commonmark_render);
132141
cmark_syntax_extension_set_plaintext_render_func(ext, commonmark_render);
133142
cmark_syntax_extension_set_html_render_func(ext, html_render);
143+
cmark_syntax_extension_set_xml_attr_func(ext, xml_attr);
134144

135145
return ext;
136146
}

0 commit comments

Comments
 (0)