Skip to content

Decouple SoftBreakMode from significantNewlines#141

Merged
dereuromark merged 3 commits intomasterfrom
decouple-soft-break-from-significant-newlines
Mar 29, 2026
Merged

Decouple SoftBreakMode from significantNewlines#141
dereuromark merged 3 commits intomasterfrom
decouple-soft-break-from-significant-newlines

Conversation

@dereuromark
Copy link
Copy Markdown
Contributor

@dereuromark dereuromark commented Mar 28, 2026

Summary

  • Removes automatic SoftBreakMode::Break when significantNewlines is enabled
  • These two features are now independent, as they serve different purposes:
    • significantNewlines: markdown-like block interruption (parser behavior)
    • SoftBreakMode: visible line breaks (renderer behavior)

Breaking Change

Users relying on withSignificantNewlines() to render soft breaks as <br> need to explicitly set the mode:

// Before (implicit)
$converter = DjotConverter::withSignificantNewlines();

// After (explicit)
$converter = DjotConverter::withSignificantNewlines(
    softBreakMode: SoftBreakMode::Break,
);

See UPGRADE.md for full migration guide.

Rationale

The previous bundling was confusing because:

  • The factory method name didn't suggest it also changed soft break rendering
  • Users wanting markdown-style block interruption didn't necessarily want visible soft breaks (or vice versa)

Additionally, SoftBreakMode::Break is rarely needed in Djot because hard breaks are simple and visible:

Line one\
Line two

Compare to Markdown's awkward options:

  • Two trailing spaces (invisible, easy to miss/delete)
  • <br> HTML tag (verbose)

In Djot, if you want visible line breaks, you explicitly add \ - it's intentional and clear. This makes SoftBreakMode::Break a niche feature for specific use cases like importing content or poetry/lyrics where adding \ to every line would be tedious.

Previously, enabling significantNewlines would automatically set
SoftBreakMode::Break. These two features serve different purposes:

- significantNewlines: markdown-like block interruption (parser)
- SoftBreakMode: visible line breaks (renderer)

They are now independent. Users wanting the previous behavior
should explicitly pass softBreakMode: SoftBreakMode::Break.

This is a breaking change - see UPGRADE.md for migration guide.
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.21%. Comparing base (5b6b08f) to head (15ba0e6).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #141      +/-   ##
============================================
- Coverage     94.21%   94.21%   -0.01%     
+ Complexity     2570     2569       -1     
============================================
  Files            88       88              
  Lines          6847     6845       -2     
============================================
- Hits           6451     6449       -2     
  Misses          396      396              

☔ 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 added bug Something isn't working bc-breaking labels Mar 28, 2026
@dereuromark dereuromark marked this pull request as ready for review March 29, 2026 17:35
@dereuromark dereuromark merged commit 7229222 into master Mar 29, 2026
6 checks passed
@dereuromark dereuromark deleted the decouple-soft-break-from-significant-newlines branch March 29, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bc-breaking bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant