File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -952,6 +952,29 @@ static void source_pos(test_batch_runner *runner) {
952
952
cmark_node_free (doc );
953
953
}
954
954
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
+
955
978
static void ref_source_pos (test_batch_runner * runner ) {
956
979
static const char markdown [] =
957
980
"Let's try [reference] links.\n"
@@ -1002,6 +1025,7 @@ int main() {
1002
1025
test_safe (runner );
1003
1026
test_feed_across_line_ending (runner );
1004
1027
source_pos (runner );
1028
+ source_pos_2 (runner );
1005
1029
ref_source_pos (runner );
1006
1030
1007
1031
test_print_summary (runner );
You can’t perform that action at this time.
0 commit comments