Skip to content

Fix: strip surplus indent on over-indented list-item paragraph continuation#239

Merged
dereuromark merged 1 commit into
masterfrom
fix/list-item-paragraph-overindent
Jun 10, 2026
Merged

Fix: strip surplus indent on over-indented list-item paragraph continuation#239
dereuromark merged 1 commit into
masterfrom
fix/list-item-paragraph-overindent

Conversation

@dereuromark

Copy link
Copy Markdown
Contributor

Problem

A tight list-item paragraph continuation line indented more than the item's
content indent kept the surplus whitespace in the rendered inline text.

Input:

- a
  - b
    c

Before this fix djot-php rendered the continuation as c (two leading
spaces preserved):

<ul>
<li>
a
- b
  c
</li>
</ul>

Canonical djot.js (the djot/djot npm package) renders every indentation
variant of this case identically, with the continuation stripped to c. The
four variants (c flush, one-space, content-indent, over-indented) should all
produce the same output.

Root cause

In BlockParser, list-item continuation lines are collected with their indent
kept relative to the item content indent (stripLeadingIndent($nextLine, $contentIndent)).
That relative indentation is needed for the branch that parses an item's lines
as nested blocks (code fences, blockquotes, etc.).

The tight single-paragraph branch, however, joined those lines and handed them
straight to the inline parser. The inline parser emits a soft break for each
newline without trimming leading whitespace, so any surplus indent leaked into
the text. The dedicated paragraph collector (tryParseParagraph) already trims
leading whitespace on continuation lines per the djot soft-break rule; the list
path did not.

Fix

In the single-paragraph branch only, strip all leading whitespace on the
collected continuation lines before inline parsing, matching tryParseParagraph
and canonical djot.js. The block-parse branch is untouched, so indentation
remains significant where it matters.

Result

All four indentation variants now match canonical djot.js output, and the
official conformance suite stays green.

…uation

A tight list-item paragraph continuation line indented more than the item
content indent kept the surplus whitespace in the inline output (an
over-indented "c" rendered as "  c"). The block-parse branch genuinely needs
the relative indentation, but the single-paragraph branch fed the collected
lines straight to the inline parser, which does not strip leading whitespace
on soft breaks the way tryParseParagraph does.

Strip all leading whitespace on continuation lines in the single-paragraph
branch, matching the djot soft-break rule and canonical djot.js, which renders
every indentation variant of the case identically.
@dereuromark dereuromark added the bug Something isn't working label Jun 10, 2026
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.89%. Comparing base (ae55a79) to head (26652cb).

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #239   +/-   ##
=========================================
  Coverage     91.89%   91.89%           
  Complexity     3527     3527           
=========================================
  Files           106      106           
  Lines          9970     9970           
=========================================
  Hits           9162     9162           
  Misses          808      808           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dereuromark dereuromark merged commit 416c2fc into master Jun 10, 2026
6 checks passed
@dereuromark dereuromark deleted the fix/list-item-paragraph-overindent branch June 10, 2026 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant