summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-01-16 22:00:41 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-01-16 22:00:41 -0800
commitc2e76eae80bb635557ff87e36334cc5ce67e10dc (patch)
tree7c35a447938c003c9d1dedf5492df93d2de99aca /src
parent15865e2f6b912e81536142bb408b5d698e4d898f (diff)
Fixed #285 in cmark.
Diffstat (limited to 'src')
-rw-r--r--src/blocks.c27
1 files 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);
}