Skip to content

Separate soft break mode from significantNewlines parsing#126

Merged
dereuromark merged 3 commits intomasterfrom
feature/soft-break-mode-separation
Mar 25, 2026
Merged

Separate soft break mode from significantNewlines parsing#126
dereuromark merged 3 commits intomasterfrom
feature/soft-break-mode-separation

Conversation

@dereuromark
Copy link
Copy Markdown
Contributor

@dereuromark dereuromark commented Mar 25, 2026

Summary

  • Adds optional softBreakMode parameter to DjotConverter constructor and withSignificantNewlines() factory
  • When explicitly provided, overrides automatic behavior
  • Backwards compatible: significantNewlines alone still implies <br> soft breaks

Motivation

The significantNewlines mode couples two unrelated concerns:

  1. Parsing relaxation - blocks can interrupt paragraphs, nested lists don't need blank lines
  2. Rendering behavior - soft breaks become visible <br> tags

This change allows using relaxed parsing without <br> tags:

// Relaxed parsing with normal soft breaks (no <br>)
$converter = DjotConverter::withSignificantNewlines(
    softBreakMode: SoftBreakMode::Space,
);

// Or via constructor
$converter = new DjotConverter(
    significantNewlines: true,
    softBreakMode: SoftBreakMode::Space,
);

@dereuromark dereuromark force-pushed the feature/soft-break-mode-separation branch from 875ed52 to 4986515 Compare March 25, 2026 08:12
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.94%. Comparing base (79a8a34) to head (49bd3b6).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #126      +/-   ##
============================================
+ Coverage     93.92%   93.94%   +0.01%     
- Complexity     2383     2384       +1     
============================================
  Files            81       81              
  Lines          6306     6310       +4     
============================================
+ Hits           5923     5928       +5     
+ Misses          383      382       -1     

☔ 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.

@dereuromark dereuromark force-pushed the feature/soft-break-mode-separation branch from 4986515 to a4e7676 Compare March 25, 2026 08:18
Previously, enabling `significantNewlines` mode automatically made soft
breaks render as `<br>` tags. This couples two unrelated concerns:
1. Parsing relaxation (blocks can interrupt paragraphs)
2. Rendering behavior (soft breaks become visible)

This change separates these concerns by:
- Adding an optional `softBreakMode` parameter to the constructor
- When explicitly provided, it overrides the automatic behavior
- When null (default), `significantNewlines` still implies `<br>` for
  backwards compatibility
@dereuromark dereuromark force-pushed the feature/soft-break-mode-separation branch from a4e7676 to 800765a Compare March 25, 2026 08:19
Previously, the immediate nesting path (significantNewlines mode) would
break on any blank line within nested content, causing blank lines
between nested list items to split them into separate lists.

Now both nesting paths (immediate and standard) handle blank lines
consistently - they continue collecting nested content across blank
lines, only breaking when returning to parent indent level.
Documents how blank lines between list items affect rendering,
with examples showing the difference between tight lists (no <p>
tags) and loose lists (wrapped in <p> tags).
@dereuromark dereuromark merged commit 0c866c8 into master Mar 25, 2026
4 checks passed
@dereuromark dereuromark deleted the feature/soft-break-mode-separation branch March 25, 2026 08:31
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