From c850185a72e94968c372a27172d415d5a488eee6 Mon Sep 17 00:00:00 2001 From: mdave0 <29395487+mdave0@users.noreply.github.com> Date: Tue, 20 Jan 2026 00:53:45 -0500 Subject: [PATCH] Fix HTML comment blocks inside list items Allow outdented empty lines to remain inside HTML blocks when parsing list items, and add a regression fixture for issue #1144. --- lib/rules_block/html_block.mjs | 5 +++- .../markdown-it/commonmark_extras.txt | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/rules_block/html_block.mjs b/lib/rules_block/html_block.mjs index 197520f..168da28 100644 --- a/lib/rules_block/html_block.mjs +++ b/lib/rules_block/html_block.mjs @@ -46,7 +46,10 @@ export default function html_block (state, startLine, endLine, silent) { // Let's roll down till block end. if (!HTML_SEQUENCES[i][1].test(lineText)) { for (; nextLine < endLine; nextLine++) { - if (state.sCount[nextLine] < state.blkIndent) { break } + if (state.sCount[nextLine] < state.blkIndent) { + // Allow empty lines to stay inside list items per CommonMark rules. + if (!(state.listIndent >= 0 && state.isEmpty(nextLine))) { break } + } pos = state.bMarks[nextLine] + state.tShift[nextLine] max = state.eMarks[nextLine] diff --git a/test/fixtures/markdown-it/commonmark_extras.txt b/test/fixtures/markdown-it/commonmark_extras.txt index 558c011..35dfc64 100644 --- a/test/fixtures/markdown-it/commonmark_extras.txt +++ b/test/fixtures/markdown-it/commonmark_extras.txt @@ -740,3 +740,29 @@ Html in image description .

item
+para
+ +c
+