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

Function source_pos

api_test/main.c:1001–1064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

999}
1000
1001static void source_pos(test_batch_runner *runner) {
1002 static const char markdown[] =
1003 "# Hi **there*.\n"
1004 "\n"
1005 "Hello &ldquo; <http://www.google.com>\n"
1006 "there `hi` -- [okay](www.google.com (ok)).\n"
1007 "\n"
1008 "> 1. Okay.\n"
1009 "> Sure.\n"
1010 ">\n"
1011 "> 2. Yes, okay.\n"
1012 "> ![ok](hi \"yes\")\n";
1013
1014 cmark_node *doc = cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT);
1015 char *xml = cmark_render_xml(doc, CMARK_OPT_DEFAULT | CMARK_OPT_SOURCEPOS);
1016 STR_EQ(runner, xml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1017 "<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n"
1018 "<document sourcepos=\"1:1-10:20\" xmlns=\"http://commonmark.org/xml/1.0\">\n"
1019 " <heading sourcepos=\"1:1-1:14\" level=\"1\">\n"
1020 " <text sourcepos=\"1:3-1:6\" xml:space=\"preserve\">Hi *</text>\n"
1021 " <emph sourcepos=\"1:7-1:13\">\n"
1022 " <text sourcepos=\"1:8-1:12\" xml:space=\"preserve\">there</text>\n"
1023 " </emph>\n"
1024 " <text sourcepos=\"1:14-1:14\" xml:space=\"preserve\">.</text>\n"
1025 " </heading>\n"
1026 " <paragraph sourcepos=\"3:1-4:42\">\n"
1027 " <text sourcepos=\"3:1-3:14\" xml:space=\"preserve\">Hello “ </text>\n"
1028 " <link sourcepos=\"3:15-3:37\" destination=\"http://www.google.com\">\n"
1029 " <text sourcepos=\"3:16-3:36\" xml:space=\"preserve\">http://www.google.com</text>\n"
1030 " </link>\n"
1031 " <softbreak />\n"
1032 " <text sourcepos=\"4:1-4:6\" xml:space=\"preserve\">there </text>\n"
1033 " <code sourcepos=\"4:8-4:9\" xml:space=\"preserve\">hi</code>\n"
1034 " <text sourcepos=\"4:11-4:14\" xml:space=\"preserve\"> -- </text>\n"
1035 " <link sourcepos=\"4:15-4:41\" destination=\"www.google.com\" title=\"ok\">\n"
1036 " <text sourcepos=\"4:16-4:19\" xml:space=\"preserve\">okay</text>\n"
1037 " </link>\n"
1038 " <text sourcepos=\"4:42-4:42\" xml:space=\"preserve\">.</text>\n"
1039 " </paragraph>\n"
1040 " <block_quote sourcepos=\"6:1-10:20\">\n"
1041 " <list sourcepos=\"6:3-10:20\" type=\"ordered\" start=\"1\" delim=\"period\" tight=\"false\">\n"
1042 " <item sourcepos=\"6:3-8:1\">\n"
1043 " <paragraph sourcepos=\"6:6-7:10\">\n"
1044 " <text sourcepos=\"6:6-6:10\" xml:space=\"preserve\">Okay.</text>\n"
1045 " <softbreak />\n"
1046 " <text sourcepos=\"7:6-7:10\" xml:space=\"preserve\">Sure.</text>\n"
1047 " </paragraph>\n"
1048 " </item>\n"
1049 " <item sourcepos=\"9:3-10:20\">\n"
1050 " <paragraph sourcepos=\"9:6-10:20\">\n"
1051 " <text sourcepos=\"9:6-9:15\" xml:space=\"preserve\">Yes, okay.</text>\n"
1052 " <softbreak />\n"
1053 " <image sourcepos=\"10:6-10:20\" destination=\"hi\" title=\"yes\">\n"
1054 " <text sourcepos=\"10:8-10:9\" xml:space=\"preserve\">ok</text>\n"
1055 " </image>\n"
1056 " </paragraph>\n"
1057 " </item>\n"
1058 " </list>\n"

Callers 1

mainFunction · 0.85

Calls 4

cmark_parse_documentFunction · 0.85
cmark_render_xmlFunction · 0.85
STR_EQFunction · 0.85
cmark_node_freeFunction · 0.85

Tested by

no test coverage detected