Skip to content

Commit 1424dac

Browse files
jmschonfeldQuietMisdreavus
authored andcommitted
Preserve leading newlines when CMARK_OPT_PRESERVE_WHITESPACE is set
rdar://79148254
1 parent cea3e64 commit 1424dac

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

api_test/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,11 @@ static void preserve_whitespace_opt(test_batch_runner *runner) {
12011201
check_markdown_plaintext(runner, "hel\nworld\nlo");
12021202
check_markdown_plaintext(runner, " hel \n world \n lo ");
12031203
check_markdown_plaintext(runner, " hello \n \n world ");
1204+
check_markdown_plaintext(runner, "\n");
1205+
check_markdown_plaintext(runner, "\n\n\n");
1206+
check_markdown_plaintext(runner, "\nHello");
1207+
check_markdown_plaintext(runner, "Hello\n");
1208+
check_markdown_plaintext(runner, "\nHello\n");
12041209
}
12051210

12061211
static void check_markdown_attributes_node(test_batch_runner *runner, char *markdown, cmark_node_type expectedType, char *expectedAttributes) {

src/blocks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ static void add_text_to_container(cmark_parser *parser, cmark_node *container,
14161416
container = finalize(parser, container);
14171417
assert(parser->current != NULL);
14181418
}
1419-
} else if (parser->blank) {
1419+
} else if (parser->blank && (parser->options & CMARK_OPT_PRESERVE_WHITESPACE) == 0) {
14201420
// ??? do nothing
14211421
} else if (accepts_lines(S_type(container))) {
14221422
if (S_type(container) == CMARK_NODE_HEADING &&

0 commit comments

Comments
 (0)