Skip to content

Strip leading whitespace from paragraph content#115

Merged
dereuromark merged 1 commit intomasterfrom
fix/paragraph-leading-whitespace
Mar 23, 2026
Merged

Strip leading whitespace from paragraph content#115
dereuromark merged 1 commit intomasterfrom
fix/paragraph-leading-whitespace

Conversation

@dereuromark
Copy link
Copy Markdown
Contributor

Summary

  • Fix paragraph parsing to strip leading whitespace from content, matching the JS reference implementation

The JS reference strips all leading whitespace from paragraph text:

  • ' text'<p>text</p>

Previously, PHP was preserving the whitespace:

  • ' text'<p> text</p>

This fix applies ltrim() to both the first line and continuation lines of paragraphs.

The JS reference implementation strips all leading whitespace (spaces
and tabs) from paragraph content, both on the first line and on
continuation lines. The PHP implementation was only stripping up to
3 spaces from continuation lines, and not stripping the first line.

Before: `   text` → `<p>   text</p>`
After:  `   text` → `<p>text</p>`

This fix uses ltrim() on both the first line and continuation lines
to match the JS reference behavior.

Added 2 tests covering leading whitespace stripping.
@dereuromark dereuromark merged commit e830e68 into master Mar 23, 2026
4 checks passed
@dereuromark dereuromark deleted the fix/paragraph-leading-whitespace branch March 23, 2026 08:31
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.76%. Comparing base (844b948) to head (430cbcd).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #115   +/-   ##
=========================================
  Coverage     93.76%   93.76%           
  Complexity     2341     2341           
=========================================
  Files            79       79           
  Lines          6205     6205           
=========================================
  Hits           5818     5818           
  Misses          387      387           

☔ View full report in Codecov by Sentry.
📢 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.

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