MCPcopy Create free account
hub / github.com/commonmark/cmark / custom_nodes

Function custom_nodes

api_test/main.c:422–454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420}
421
422static void custom_nodes(test_batch_runner *runner) {
423 char *html;
424 char *man;
425 cmark_node *doc = cmark_node_new(CMARK_NODE_DOCUMENT);
426 cmark_node *p = cmark_node_new(CMARK_NODE_PARAGRAPH);
427 cmark_node_append_child(doc, p);
428 cmark_node *ci = cmark_node_new(CMARK_NODE_CUSTOM_INLINE);
429 cmark_node *str1 = cmark_node_new(CMARK_NODE_TEXT);
430 cmark_node_set_literal(str1, "Hello");
431 OK(runner, cmark_node_append_child(ci, str1), "append1");
432 OK(runner, cmark_node_set_on_enter(ci, "<ON ENTER|"), "set_on_enter");
433 OK(runner, cmark_node_set_on_exit(ci, "|ON EXIT>"), "set_on_exit");
434 STR_EQ(runner, cmark_node_get_on_enter(ci), "<ON ENTER|", "get_on_enter");
435 STR_EQ(runner, cmark_node_get_on_exit(ci), "|ON EXIT>", "get_on_exit");
436 cmark_node_append_child(p, ci);
437 cmark_node *cb = cmark_node_new(CMARK_NODE_CUSTOM_BLOCK);
438 cmark_node_set_on_enter(cb, "<on enter|");
439 // leave on_exit unset
440 STR_EQ(runner, cmark_node_get_on_exit(cb), "", "get_on_exit (empty)");
441 cmark_node_append_child(doc, cb);
442
443 html = cmark_render_html(doc, CMARK_OPT_DEFAULT);
444 STR_EQ(runner, html, "<p><ON ENTER|Hello|ON EXIT></p>\n<on enter|\n",
445 "render_html");
446 free(html);
447
448 man = cmark_render_man(doc, CMARK_OPT_DEFAULT, 0);
449 STR_EQ(runner, man, ".PP\n<ON ENTER|Hello|ON EXIT>\n<on enter|\n",
450 "render_man");
451 free(man);
452
453 cmark_node_free(doc);
454}
455
456void hierarchy(test_batch_runner *runner) {
457 cmark_node *bquote1 = cmark_node_new(CMARK_NODE_BLOCK_QUOTE);

Callers 1

mainFunction · 0.85

Calls 12

cmark_node_newFunction · 0.85
cmark_node_append_childFunction · 0.85
cmark_node_set_literalFunction · 0.85
OKFunction · 0.85
cmark_node_set_on_enterFunction · 0.85
cmark_node_set_on_exitFunction · 0.85
STR_EQFunction · 0.85
cmark_node_get_on_enterFunction · 0.85
cmark_node_get_on_exitFunction · 0.85
cmark_render_htmlFunction · 0.85
cmark_render_manFunction · 0.85
cmark_node_freeFunction · 0.85

Tested by

no test coverage detected