Skip to content

Commit 471d20c

Browse files
jmschonfeldQuietMisdreavus
authored andcommitted
Allow all whitespace when preserving whitespace
rdar://77383424
1 parent a595ea9 commit 471d20c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

api_test/main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,10 +1179,18 @@ static void check_markdown_plaintext(test_batch_runner *runner, char *markdown)
11791179
cmark_node *textNode = cmark_node_first_child(pg);
11801180
INT_EQ(runner, cmark_node_get_type(textNode), CMARK_NODE_TEXT, "markdown '%s' did not produce a text node inside the paragraph node", markdown);
11811181
const char *text = cmark_node_get_literal(textNode);
1182-
STR_EQ(runner, text, markdown, "markdown '%s' resulted in '%s'", markdown, text);
1182+
OK(runner, text, "Text literal for '%s' was null", markdown);
1183+
if (text) {
1184+
STR_EQ(runner, text, markdown, "markdown '%s' resulted in '%s'", markdown, text);
1185+
} else {
1186+
SKIP(runner, 1);
1187+
}
1188+
cmark_node_free(doc);
11831189
}
11841190

11851191
static void preserve_whitespace_opt(test_batch_runner *runner) {
1192+
check_markdown_plaintext(runner, " ");
1193+
check_markdown_plaintext(runner, " ");
11861194
check_markdown_plaintext(runner, "hello");
11871195
check_markdown_plaintext(runner, "hello ");
11881196
check_markdown_plaintext(runner, " hello");

src/blocks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ static cmark_node *finalize(cmark_parser *parser, cmark_node *b) {
308308
case CMARK_NODE_PARAGRAPH:
309309
{
310310
has_content = resolve_reference_link_definitions(parser, b);
311-
if (!has_content) {
311+
if (!has_content && (parser->options & CMARK_OPT_PRESERVE_WHITESPACE) == 0) {
312312
// remove blank node (former reference def)
313313
cmark_node_free(b);
314314
}

0 commit comments

Comments
 (0)