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 d161268d41f93457e041f2591de320577dfcbb79
parent 762aee7f0dae8ebb328d65949474751540efc8e5
Author: Martin Mitas <mity@morous.org>
Date:   Sat,  8 Oct 2016 23:55:43 +0200

Minor fixes.

Diffstat:
Mmd4c/md4c.c | 21++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/md4c/md4c.c b/md4c/md4c.c @@ -1555,6 +1555,13 @@ redo_indentation_after_blockquote_mark: if(md_is_html_block_end_condition(ctx, off) == ctx->html_block_type) { /* Make sure this is the last line of the block. */ ctx->html_block_type = 0; + + /* Some end conditions serve as blank lines at the same time. */ + if(ISNEWLINE(off)) { + line->type = MD_LINE_BLANK; + line->indent = 0; + goto done; + } } line->type = MD_LINE_HTML; @@ -1575,9 +1582,7 @@ redo_indentation_after_blockquote_mark: } /* Check whether we are indented code line. - * Note indented code block cannot interrupt paragraph. - * Keep this is as the first check after the blank line: The checks below - * then do not need to verify that indentation < 4. */ + * Note indented code block cannot interrupt paragraph. */ if((pivot_line->type == MD_LINE_BLANK || pivot_line->type == MD_LINE_INDENTEDCODE) && line->indent >= ctx->code_indent_offset) { @@ -1588,7 +1593,7 @@ redo_indentation_after_blockquote_mark: /* Check whether we are ATX header. * (We check the indentation to fix http://spec.commonmark.org/0.26/#example-40) */ - if(line->indent < 4 && CH(off) == _T('#')) { + if(line->indent < ctx->code_indent_offset && CH(off) == _T('#')) { if(md_is_atxheader_line(ctx, off, &line->beg, &off) == 0) { line->type = MD_LINE_ATXHEADER; goto done; @@ -1596,7 +1601,7 @@ redo_indentation_after_blockquote_mark: } /* Check whether we are Setext underline. */ - if(line->indent < 4 && pivot_line->type == MD_LINE_TEXT + if(line->indent < ctx->code_indent_offset && pivot_line->type == MD_LINE_TEXT && line->quote_level == pivot_line->quote_level && (CH(off) == _T('=') || CH(off) == _T('-'))) { @@ -1609,7 +1614,7 @@ redo_indentation_after_blockquote_mark: /* Check whether we are thematic break line. * (We check the indentation to fix http://spec.commonmark.org/0.26/#example-19) * (Keep this after check for Setext underline as that one has higher priority). */ - if(line->indent < 4 && ISANYOF(off, _T("-_*"))) { + if(line->indent < ctx->code_indent_offset && ISANYOF(off, _T("-_*"))) { if(md_is_hr_line(ctx, off, &off) == 0) { line->type = MD_LINE_HR; goto done; @@ -1626,7 +1631,9 @@ redo_indentation_after_blockquote_mark: } /* Check whether we are start of raw HTML block. */ - if(CH(off) == _T('<') && !(ctx->r.flags & MD_FLAG_NOHTMLBLOCKS)) { + if(CH(off) == _T('<') && !(ctx->r.flags & MD_FLAG_NOHTMLBLOCKS) + && line->indent < ctx->code_indent_offset) + { ctx->html_block_type = md_is_html_block_start_condition(ctx, off); if(ctx->html_block_type > 0) { /* The line itself also may immediately close the block. */