From d59a1010c594ca5705efdbd663b98a2a71b42ff6 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Mon, 4 Jun 2018 20:50:59 +0800 Subject: [PATCH] highlighter: bug fix about HTML comments inside a fenced code block --- src/hgmarkdownhighlighter.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hgmarkdownhighlighter.cpp b/src/hgmarkdownhighlighter.cpp index f497ea2c..a850ee6b 100644 --- a/src/hgmarkdownhighlighter.cpp +++ b/src/hgmarkdownhighlighter.cpp @@ -169,8 +169,13 @@ void HGMarkdownHighlighter::highlightBlock(const QString &text) // Set current block's user data. updateBlockUserData(blockNum, text); + int preState = previousBlockState(); + bool inCodeblock = preState == HighlightBlockState::CodeBlock + || preState == HighlightBlockState::CodeBlockStart; + // If it is a block inside HTML comment, just skip it. - if (isBlockInsideCommentRegion(curBlock)) { + // Pay attention to distinguish the HTML comments inside a fenced code block. + if (!inCodeblock && isBlockInsideCommentRegion(curBlock)) { setCurrentBlockState(HighlightBlockState::Comment); goto exit; }