Skip to content

Commit 462cab4

Browse files
committed
add failing test
1 parent 3a440af commit 462cab4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

api_test/main.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,29 @@ static void source_pos(test_batch_runner *runner) {
952952
cmark_node_free(doc);
953953
}
954954

955+
static void source_pos_2(test_batch_runner *runner) {
956+
static const char markdown[] =
957+
"*first*\n"
958+
"second\n";
959+
960+
cmark_node *doc = cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT);
961+
char *xml = cmark_render_xml(doc, CMARK_OPT_DEFAULT | CMARK_OPT_SOURCEPOS);
962+
STR_EQ(runner, xml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
963+
"<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n"
964+
"<document sourcepos=\"1:1-2:6\" xmlns=\"http://commonmark.org/xml/1.0\">\n"
965+
" <paragraph sourcepos=\"1:1-2:6\">\n"
966+
" <emph sourcepos=\"1:1-1:7\">\n"
967+
" <text sourcepos=\"1:2-1:6\" xml:space=\"preserve\">first</text>\n"
968+
" </emph>\n"
969+
" <softbreak />\n"
970+
" <text sourcepos=\"2:1-2:6\" xml:space=\"preserve\">second</text>\n"
971+
" </paragraph>\n"
972+
"</document>\n",
973+
"sourcepos are as expected");
974+
free(xml);
975+
cmark_node_free(doc);
976+
}
977+
955978
static void ref_source_pos(test_batch_runner *runner) {
956979
static const char markdown[] =
957980
"Let's try [reference] links.\n"
@@ -1002,6 +1025,7 @@ int main() {
10021025
test_safe(runner);
10031026
test_feed_across_line_ending(runner);
10041027
source_pos(runner);
1028+
source_pos_2(runner);
10051029
ref_source_pos(runner);
10061030

10071031
test_print_summary(runner);

0 commit comments

Comments
 (0)