Skip to content

Formatter: Improve text content formatting and whitespace preservation#823

Merged
marcoroth merged 1 commit into
mainfrom
improve-text-content-formatting
Nov 9, 2025
Merged

Formatter: Improve text content formatting and whitespace preservation#823
marcoroth merged 1 commit into
mainfrom
improve-text-content-formatting

Conversation

@marcoroth

@marcoroth marcoroth commented Nov 9, 2025

Copy link
Copy Markdown
Owner

This pull request improves text content formatting by preserving leading and trailing whitespace for inline elements with text-only content, while ensuring block-level elements continue to have their whitespace normalized correctly.

Input

<span>
  And on the other hand one can not remove whitespace entirely
</span>

Before

<span>And on the other hand one can not remove whitespace entirely</span>

After

<span> And on the other hand one can not remove whitespace entirely </span>

Input

<html>
<head></head>
<body>
<div class="main">
<p>
<strong>Bold Heading:</strong><br>
<%= Date.current %>: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua.
</p>
</div>
</body>
</html>

Before

<html>
  <head></head>
  <body>
    <div class="main">
      <p>
        <strong>Bold Heading:</strong><br><%= Date.current %>
        : Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
        eiusmod tempor incididunt ut labore et dolore magna aliqua.
      </p>
    </div>
  </body>
</html>

After

<html>
  <head></head>
  <body>
    <div class="main">
      <p>
        <strong>Bold Heading:</strong><br>
        <%= Date.current %>: Lorem ipsum dolor sit amet, consectetur adipiscing
        elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
      </p>
    </div>
  </body>
</html>

Resolves #609
Resolves #806

@marcoroth marcoroth changed the title Formatter: Improve Text Content Formatting Formatter: Improve Text Content and Whitespace Formatting Nov 9, 2025
@marcoroth marcoroth changed the title Formatter: Improve Text Content and Whitespace Formatting Formatter: Improve text content formatting and whitespace preservation Nov 9, 2025
@marcoroth marcoroth merged commit 22a1eba into main Nov 9, 2025
12 checks passed
@marcoroth marcoroth deleted the improve-text-content-formatting branch November 9, 2025 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Formatter: some elements are duplicated on format Formatter: Whitespace inserted and removed in various situations

1 participant