Browse Source

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.
pull/1146/head
mdave0 3 months ago
parent
commit
c850185a72
  1. 5
      lib/rules_block/html_block.mjs
  2. 26
      test/fixtures/markdown-it/commonmark_extras.txt

5
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]

26
test/fixtures/markdown-it/commonmark_extras.txt

@ -740,3 +740,29 @@ Html in image description
.
<p><img src="image.png" alt="text &lt;textarea&gt; text"></p>
.
Issue #1144: HTML comment block in list item with blank line
.
1. item
para
<!--
a
b
-->
c
.
<ol>
<li>
<p>item</p>
<p>para</p>
<!--
a
b
-->
<p>c</p>
</li>
</ol>
.

Loading…
Cancel
Save