From c2e76eae80bb635557ff87e36334cc5ce67e10dc Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 16 Jan 2015 22:00:41 -0800 Subject: Fixed #285 in cmark. --- src/blocks.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/blocks.c b/src/blocks.c index e5669ea..b2ea5ad 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -593,14 +593,23 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes) all_matched = false; } } else { - // skip optional spaces of fence offset - i = container->as.code.fence_offset; - while (i > 0 && peek_at(&input, offset) == ' ') { - offset++; - i--; + if (container->as.code.fence_length == -1) { + // -1 means we've seen closer + all_matched = false; + if (blank) { + container->last_line_blank = + true; + } + } else { + // skip opt. spaces of fence offset + i = container->as.code.fence_offset; + while (i > 0 && + peek_at(&input, offset) == ' ') { + offset++; + i--; + } } } - } else if (container->type == NODE_HEADER) { // a header can never contain more than one line @@ -829,8 +838,10 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes) } if (matched) { - // if closing fence, don't add line to container; instead, close it: - container = finalize(parser, container); + // if closing fence, set fence length to -1. + // it will be closed when the next line is + // processed. + container->as.code.fence_length = -1; } else { add_line(container, &input, offset); } -- cgit v1.2.3