summaryrefslogtreecommitdiff
path: root/api_test
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-11-13 09:47:50 -0800
committerGitHub <noreply@github.com>2018-11-13 09:47:50 -0800
commitb1556b3407a4349b9a1f4f58d8677eda0ead09c1 (patch)
tree2ee14a588403d9c9ed1888d6270a6f6ca30668ad /api_test
parent3a440af3ba874289ef33ac6bbf2da90040c123d6 (diff)
parentd479c28a631731543e6276f807155388aa71acde (diff)
Merge pull request #275 from github/inline-sourcepos-off
correct sourcepos for emphasis inlines
Diffstat (limited to 'api_test')
-rw-r--r--api_test/main.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/api_test/main.c b/api_test/main.c
index a843530..1f1f77f 100644
--- a/api_test/main.c
+++ b/api_test/main.c
@@ -952,6 +952,53 @@ static void source_pos(test_batch_runner *runner) {
cmark_node_free(doc);
}
+static void source_pos_inlines(test_batch_runner *runner) {
+ {
+ static const char markdown[] =
+ "*first*\n"
+ "second\n";
+
+ cmark_node *doc = cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT);
+ char *xml = cmark_render_xml(doc, CMARK_OPT_DEFAULT | CMARK_OPT_SOURCEPOS);
+ STR_EQ(runner, xml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n"
+ "<document sourcepos=\"1:1-2:6\" xmlns=\"http://commonmark.org/xml/1.0\">\n"
+ " <paragraph sourcepos=\"1:1-2:6\">\n"
+ " <emph sourcepos=\"1:1-1:7\">\n"
+ " <text sourcepos=\"1:2-1:6\" xml:space=\"preserve\">first</text>\n"
+ " </emph>\n"
+ " <softbreak />\n"
+ " <text sourcepos=\"2:1-2:6\" xml:space=\"preserve\">second</text>\n"
+ " </paragraph>\n"
+ "</document>\n",
+ "sourcepos are as expected");
+ free(xml);
+ cmark_node_free(doc);
+ }
+ {
+ static const char markdown[] =
+ "*first\n"
+ "second*\n";
+
+ cmark_node *doc = cmark_parse_document(markdown, sizeof(markdown) - 1, CMARK_OPT_DEFAULT);
+ char *xml = cmark_render_xml(doc, CMARK_OPT_DEFAULT | CMARK_OPT_SOURCEPOS);
+ STR_EQ(runner, xml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n"
+ "<document sourcepos=\"1:1-2:7\" xmlns=\"http://commonmark.org/xml/1.0\">\n"
+ " <paragraph sourcepos=\"1:1-2:7\">\n"
+ " <emph sourcepos=\"1:1-2:7\">\n"
+ " <text sourcepos=\"1:2-1:6\" xml:space=\"preserve\">first</text>\n"
+ " <softbreak />\n"
+ " <text sourcepos=\"2:1-2:6\" xml:space=\"preserve\">second</text>\n"
+ " </emph>\n"
+ " </paragraph>\n"
+ "</document>\n",
+ "sourcepos are as expected");
+ free(xml);
+ cmark_node_free(doc);
+ }
+}
+
static void ref_source_pos(test_batch_runner *runner) {
static const char markdown[] =
"Let's try [reference] links.\n"
@@ -1002,6 +1049,7 @@ int main() {
test_safe(runner);
test_feed_across_line_ending(runner);
source_pos(runner);
+ source_pos_inlines(runner);
ref_source_pos(runner);
test_print_summary(runner);