From 209ac5d2be3ddc9b0ff814c25903cd33f7dc94b4 Mon Sep 17 00:00:00 2001 From: Ben Trask Date: Fri, 20 Mar 2015 20:37:58 -0400 Subject: Add CRLF/CR handling to inlines.c. --- src/inlines.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/inlines.c b/src/inlines.c index 3e298de..7175327 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -576,7 +576,7 @@ static cmark_node* handle_backslash(subject *subj) if (cmark_ispunct(nextchar)) { // only ascii symbols and newline can be escaped advance(subj); return make_str(cmark_chunk_dup(&subj->input, subj->pos - 1, 1)); - } else if (nextchar == '\n') { + } else if (nextchar == '\r' || nextchar == '\n') { advance(subj); return make_linebreak(); } else { @@ -928,9 +928,9 @@ static cmark_node* handle_newline(subject *subj) static int subject_find_special_char(subject *subj, int options) { - // "\n\\`&_*[]pos = endpos; // if we're at a newline, strip trailing spaces. - if (peek_char(subj) == '\n') { + if (peek_char(subj) == '\r' || peek_char(subj) == '\n') { cmark_chunk_rtrim(&contents); } @@ -1076,7 +1077,7 @@ static void spnl(subject* subj) bool seen_newline = false; while (peek_char(subj) == ' ' || (!seen_newline && - (seen_newline = peek_char(subj) == '\n'))) { + (seen_newline = peek_char(subj) == '\r' || peek_char(subj) == '\n'))) { advance(subj); } } @@ -1134,7 +1135,7 @@ int cmark_parse_reference_inline(cmark_strbuf *input, cmark_reference_map *refma while (peek_char(&subj) == ' ') { advance(&subj); } - if (peek_char(&subj) == '\n') { + if (peek_char(&subj) == '\r' || peek_char(&subj) == '\n') { advance(&subj); } else if (peek_char(&subj) != 0) { return 0; -- cgit v1.2.3