summaryrefslogtreecommitdiff
path: root/src/inlines.c
diff options
context:
space:
mode:
authorBen Trask <bentrask@comcast.net>2015-03-20 20:37:58 -0400
committerBen Trask <bentrask@comcast.net>2015-04-07 09:26:07 -0400
commit209ac5d2be3ddc9b0ff814c25903cd33f7dc94b4 (patch)
tree2bcac572ea9251c164ddabf353ba22790b1d895e /src/inlines.c
parent5a3241c1cec67bbdee20c18b95c5fc0695df5edf (diff)
Add CRLF/CR handling to inlines.c.
Diffstat (limited to 'src/inlines.c')
-rw-r--r--src/inlines.c13
1 files changed, 7 insertions, 6 deletions
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\\`&_*[]<!"
+ // "\r\n\\`&_*[]<!"
static const int8_t SPECIAL_CHARS[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
@@ -995,6 +995,7 @@ static int parse_inline(subject* subj, cmark_node * parent, int options)
return 0;
}
switch(c) {
+ case '\r':
case '\n':
new_inl = handle_newline(subj);
break;
@@ -1046,7 +1047,7 @@ static int parse_inline(subject* subj, cmark_node * parent, int options)
subj->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;