Fix: strip surplus indent on over-indented list-item paragraph continuation#239
Merged
Merged
Conversation
…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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Before this fix djot-php rendered the continuation as
c(two leadingspaces preserved):
Canonical djot.js (the
djot/djotnpm package) renders every indentationvariant of this case identically, with the continuation stripped to
c. Thefour variants (
cflush, one-space, content-indent, over-indented) should allproduce the same output.
Root cause
In
BlockParser, list-item continuation lines are collected with their indentkept 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 trimsleading 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
tryParseParagraphand 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.