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 a847f5522e7129f529aa96ec34ba340effb25afe
parent ee3bee1a5d980e55ddeab6d2a6754deab1b0fe31
Author: Martin Mitas <mity@morous.org>
Date:   Sun,  8 Jan 2017 09:14:49 +0100

md_process_inlines: Apply new spec rules for emph/strong emph.

The spec now states that for

 ***foo***

we have to genarate

  <em><strong>foo</strong></em>

instead of

  <strong><em>foo</em></strong>

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

diff --git a/md4c/md4c.c b/md4c/md4c.c @@ -3878,21 +3878,23 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, int n_lines) case '_': case '*': /* Emphasis, strong emphasis. */ if(mark->flags & MD_MARK_OPENER) { + if((mark->end - off) % 2) { + MD_ENTER_SPAN(MD_SPAN_EM, NULL); + off++; + } while(off + 1 < mark->end) { MD_ENTER_SPAN(MD_SPAN_STRONG, NULL); off += 2; } - if(off < mark->end) - MD_ENTER_SPAN(MD_SPAN_EM, NULL); } else { - if((mark->end - off) & 0x01) { - MD_LEAVE_SPAN(MD_SPAN_EM, NULL); - off++; - } - while(off < mark->end) { + while(off + 1 < mark->end) { MD_LEAVE_SPAN(MD_SPAN_STRONG, NULL); off += 2; } + if((mark->end - off) % 2) { + MD_LEAVE_SPAN(MD_SPAN_EM, NULL); + off++; + } } break;