@@ -1417,6 +1417,46 @@ static void parser_interrupt(test_batch_runner *runner) {
14171417 cmark_syntax_extension_free (cmark_get_default_mem_allocator (), my_ext );
14181418}
14191419
1420+ static void render_spoiler (test_batch_runner * runner ) {
1421+ cmark_gfm_core_extensions_ensure_registered ();
1422+
1423+ cmark_parser * parser = cmark_parser_new (CMARK_OPT_DEFAULT );
1424+ cmark_parser_attach_syntax_extension (parser , cmark_find_syntax_extension ("spoiler" ));
1425+
1426+ {
1427+ static const char markdown [] = "we have some ||spicy text|| here" ;
1428+ cmark_parser_feed (parser , markdown , sizeof (markdown ) - 1 );
1429+
1430+ cmark_node * doc = cmark_parser_finish (parser );
1431+ char * xml = cmark_render_xml (doc , CMARK_OPT_DEFAULT );
1432+ STR_EQ (runner , xml , "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1433+ "<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n"
1434+ "<document xmlns=\"http://commonmark.org/xml/1.0\">\n"
1435+ " <paragraph>\n"
1436+ " <text xml:space=\"preserve\">we have some </text>\n"
1437+ " <spoiler>\n"
1438+ " <text xml:space=\"preserve\">spicy text</text>\n"
1439+ " </spoiler>\n"
1440+ " <text xml:space=\"preserve\"> here</text>\n"
1441+ " </paragraph>\n"
1442+ "</document>\n" , "rendering spoilers should appear correctly" );
1443+ }
1444+ {
1445+ static const char markdown [] = "we have some |non-spicy text| here" ;
1446+ cmark_parser_feed (parser , markdown , sizeof (markdown ) - 1 );
1447+
1448+ cmark_node * doc = cmark_parser_finish (parser );
1449+ char * xml = cmark_render_xml (doc , CMARK_OPT_DEFAULT );
1450+ STR_EQ (runner , xml , "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1451+ "<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n"
1452+ "<document xmlns=\"http://commonmark.org/xml/1.0\">\n"
1453+ " <paragraph>\n"
1454+ " <text xml:space=\"preserve\">we have some |non-spicy text| here</text>\n"
1455+ " </paragraph>\n"
1456+ "</document>\n" , "rendering spoilers without proper delimiters should appear correctly" );
1457+ }
1458+ }
1459+
14201460int main () {
14211461 int retval ;
14221462 test_batch_runner * runner = test_batch_runner_new ();
@@ -1452,6 +1492,7 @@ int main() {
14521492 verify_custom_attributes_node (runner );
14531493 verify_custom_attributes_node_with_footnote (runner );
14541494 parser_interrupt (runner );
1495+ render_spoiler (runner );
14551496
14561497 test_print_summary (runner );
14571498 retval = test_ok (runner ) ? 0 : 1 ;
0 commit comments