md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
git clone https://noulin.net/git/md4c.git
Log | Files | Refs | README | LICENSE

commit 9455688192a1729e08a718138975b23a11cb1a60
parent 61f9e2cbedb28e7ab3e56472c1bb02a63226c8d3
Author: Martin Mitas <mity@morous.org>
Date:   Thu, 24 Nov 2016 13:12:27 +0100

Fix some corner cases with blank lines.

Diffstat:
Mmd4c/md4c.c | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/md4c/md4c.c b/md4c/md4c.c @@ -4683,9 +4683,12 @@ redo: if(off >= ctx->size || ISNEWLINE(off)) { /* Blank line does not need any real indentation to be nested inside * a list. */ - n_parents = ctx->n_containers; + if(n_brothers + n_children == 0) { + while(n_parents < ctx->n_containers && ctx->containers[n_parents].ch != _T('>')) + n_parents++; + } - if(pivot_line->type == MD_LINE_INDENTEDCODE) { + if(pivot_line->type == MD_LINE_INDENTEDCODE && n_parents == ctx->n_containers) { line->type = MD_LINE_INDENTEDCODE; if(line->indent > ctx->code_indent_offset) line->indent -= ctx->code_indent_offset; @@ -4745,8 +4748,8 @@ redo: /* Check for start of a new container block. */ if(md_is_container_mark(ctx, line->indent, off, &off, &container)) { - line->beg = off; line->indent = md_line_indentation(ctx, off, &off); + line->beg = off; if(n_brothers + n_children == 0) { pivot_line = &md_dummy_blank_line;