From 3cc146ced9fe52a8f8b47f1f6731708c1cc4f85b Mon Sep 17 00:00:00 2001 From: Martin Mitas Date: Tue, 9 Jan 2024 02:25:05 +0100 Subject: [PATCH] md_is_html_comment: Reflect updated spec.txt. * Accept "" and "" as valid HTML comments. * HTML comment now can contain "--" --- src/md4c.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/md4c.c b/src/md4c.c index f63c0745..e61c0900 100644 --- a/src/md4c.c +++ b/src/md4c.c @@ -1201,26 +1201,13 @@ md_is_html_comment(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg, OFF return FALSE; if(CH(off+1) != _T('!') || CH(off+2) != _T('-') || CH(off+3) != _T('-')) return FALSE; - off += 4; - /* ">" and "->" must not follow the opening. */ - if(off < lines[0].end && CH(off) == _T('>')) - return FALSE; - if(off+1 < lines[0].end && CH(off) == _T('-') && CH(off+1) == _T('>')) - return FALSE; - - /* HTML comment must not contain "--", so we scan just for "--" instead - * of "-->" and verify manually that '>' follows. */ - if(md_scan_for_html_closer(ctx, _T("--"), 2, - lines, n_lines, off, max_end, p_end, &ctx->html_comment_horizon)) - { - if(*p_end < max_end && CH(*p_end) == _T('>')) { - *p_end = *p_end + 1; - return TRUE; - } - } + /* Skip only "" or "" */ + off += 2; - return FALSE; + /* Scan for ordinary comment closer "-->". */ + return md_scan_for_html_closer(ctx, _T("-->"), 3, + lines, n_lines, off, max_end, p_end, &ctx->html_comment_horizon); } static int