Skip to content

🐛 FIX: deflist: keep indented : lines as lazy paragraph continuations - #182

Open
Asimmirzac wants to merge 1 commit into
executablebooks:masterfrom
Asimmirzac:fix-deflist-lazy-continuation
Open

Asimmirzac wants to merge 1 commit into
executablebooks:masterfrom
Asimmirzac:fix-deflist-lazy-continuation

Conversation

@Asimmirzac

Copy link
Copy Markdown

Inside a definition, a line that starts with : or ~ but is indented at least as far as the definition content should be a lazy continuation of the paragraph. The deflist rule still accepted it as a paragraph terminator, so the paragraph was cut and the line became its own paragraph. In tight lists the two paragraphs are hidden, so the text was joined without the line break.

from markdown_it import MarkdownIt
from mdit_py_plugins.deflist import deflist_plugin

md = MarkdownIt("js-default").use(deflist_plugin)
print(md.render("Term\n: Definition\ncontinued\n    : not a new definition\n"))

Before:

<dl>
<dt>Term</dt>
<dd>Definition
continued: not a new definition</dd>
</dl>

After (same as markdown-it + markdown-it-deflist 3.0.1):

<dl>
<dt>Term</dt>
<dd>Definition
continued
: not a new definition</dd>
</dl>

The fix ports upstream markdown-it-deflist commit 694a9e9 ("Correct lazy paragraph continuations"). In validation mode a marker line only ends the paragraph when it is indented less than the definition content. I also noted the commit in port.yaml.

Tests: added the two upstream fixtures plus the case above to tests/fixtures/deflist.md. Two of them fail without the change, and the third (a marker in a blockquote that should not become a definition) passes with and without it.

  • pytest: 733 passed, 3 skipped, 1 xfailed
  • ruff check, ruff format --check, mypy mdit_py_plugins: clean
  • I also compared deflist output with markdown-it 14 + markdown-it-deflist 3.0.1 on 3,277 generated inputs (js-default preset). Two of them differed before this change and none differ after it.

I did not run tox or pre-commit themselves, only the tools above directly (Python 3.12).

Prepared with AI assistance (Claude Code).

🤖 Generated with Claude Code

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 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant