From 3177335b4eaf721794c15b848df1a79328035746 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sun, 15 Nov 2026 19:18:16 +0530 Subject: [PATCH] Stop a line comment at a line indented less than the block --- mdit_py_plugins/myst_blocks/index.py | 2 ++ tests/fixtures/myst_block.md | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/mdit_py_plugins/myst_blocks/index.py b/mdit_py_plugins/myst_blocks/index.py index 14fbbd3..f7437e8 100644 --- a/mdit_py_plugins/myst_blocks/index.py +++ b/mdit_py_plugins/myst_blocks/index.py @@ -65,6 +65,8 @@ def line_comment(state: StateBlock, startLine: int, endLine: int, silent: bool) pos = state.bMarks[nextLine] + state.tShift[nextLine] maximum = state.eMarks[nextLine] + if state.sCount[nextLine] < state.blkIndent: + break if state.src[pos] != "%": break token.content += "\n" + state.src[pos + 1 : maximum].rstrip() diff --git a/tests/fixtures/myst_block.md b/tests/fixtures/myst_block.md index 515daf4..debf21e 100644 --- a/tests/fixtures/myst_block.md +++ b/tests/fixtures/myst_block.md @@ -148,6 +148,18 @@ def -->
def --> . +Multiline comment in list item: +. +- a + % abc +% def +. + + +. + Indented by 4 spaces .