From 8131ec945bcd567a44aad3123dbdb841df34d380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?As=C4=B1m=20Mirza=20=C3=87iftler?= Date: Thu, 3 Dec 2026 23:42:17 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20deflist:=20keep=20indente?= =?UTF-8?q?d=20`:`=20lines=20as=20lazy=20paragraph=20continuations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inside a definition, a line such as ` : text` that is indented at least as far as the definition content ended the paragraph, because the deflist rule accepted it as a paragraph terminator. The line was then rendered as a separate paragraph and, in tight lists, glued to the previous line without a line break. Port upstream markdown-it-deflist commit 694a9e9 ("Correct lazy paragraph continuations"), which only lets a marker terminate the paragraph when it is indented less than the definition content, and add its test fixtures. Co-Authored-By: Claude Opus 5.5 --- mdit_py_plugins/deflist/index.py | 7 ++- mdit_py_plugins/deflist/port.yaml | 2 + tests/fixtures/deflist.md | 71 +++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/mdit_py_plugins/deflist/index.py b/mdit_py_plugins/deflist/index.py index f5d20d1..1061b1b 100644 --- a/mdit_py_plugins/deflist/index.py +++ b/mdit_py_plugins/deflist/index.py @@ -75,7 +75,12 @@ def deflist(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bo # quirk: validation mode validates a dd block only, not a whole deflist if state.ddIndent < 0: return False - return skipMarker(state, startLine) >= 0 + # a marker indented at least as far as the definition content + # is a lazy paragraph continuation, not a new definition + return ( + skipMarker(state, startLine) >= 0 + and state.sCount[startLine] < state.blkIndent + ) nextLine = startLine + 1 if nextLine >= endLine: diff --git a/mdit_py_plugins/deflist/port.yaml b/mdit_py_plugins/deflist/port.yaml index 203c772..a9638f0 100644 --- a/mdit_py_plugins/deflist/port.yaml +++ b/mdit_py_plugins/deflist/port.yaml @@ -3,3 +3,5 @@ date: July 12, 2017 version: 2.0.3 changes: + - Applied upstream commit 694a9e9c22d146c9315f3f614a364ce476fdab14 + (Correct lazy paragraph continuations). diff --git a/tests/fixtures/deflist.md b/tests/fixtures/deflist.md index dfc20db..291d0c4 100644 --- a/tests/fixtures/deflist.md +++ b/tests/fixtures/deflist.md @@ -246,6 +246,77 @@ test

test

. +A lazy continuation may start with a `:`, if it has enough indent. +. +apple + : > computer company + : red fruit + +orange + : > telecom company + : orange fruit + +chili's + : > restaurant company + : spicy fruit +. +
+
apple
+
+
+

computer company +: red fruit

+
+
+
orange
+
+
+

telecom company

+
+
+
orange fruit
+
chili's
+
+
+

restaurant company

+
+
+
spicy fruit
+
+. + +It may not, however, lazily act as a definition in a list. +. +> cherry +> : keyboard company +> pomegranate +: tart fruit +. +
+
+
cherry
+
keyboard company +pomegranate +: tart fruit
+
+
+. + +A paragraph continuation line indented like the definition content is kept as text. +. +Term +: Definition +continued + : not a new definition +. +
+
Term
+
Definition +continued +: not a new definition
+
+. + Indented by 4 spaces . Term 1