Skip to content

Formatter: Duplicating content multiple times #436

@sudhanshug16

Description

@sudhanshug16

Input:

<!DOCTYPE html>
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" data-theme="light">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="format-detection" content="telephone=no, date=no, address=no, email=no, url=no">
    <meta name="x-apple-disable-message-reformatting">
    <title><%= message.subject %> | NoScrubs</title>
    <%= stylesheet_link_tag "mailer", media: "all" %>
    <style>
      @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');
    </style>
    <style>
      @media only screen and (max-width: 600px) {
        .hidden-mobile {
          display: none !important;
        }
      }
      @media only screen and (min-width: 601px) {
        .hidden-desktop {
          display: none !important;
        }
      }
    </style>
  </head>
  <body  style="font-family: 'DM Sans', Arial, sans-serif;">
    <% if content_for?(:preheader) %>
      <div class="hidden">
        <%= yield :preheader %>
      </div>
    <% end %>
    <div role="article" aria-roledescription="email" aria-label="<%= message.subject %>" lang="en">
      <table border="0" cellpadding="0" cellspacing="0" width="100%" class="bg-background leading-normal text-base">
        <tr>
          <td height="32"></td>
        </tr>
        <tr>
          <td align="center">
            <table border="0" cellpadding="0" cellspacing="0" class="w-full max-w-[684px] px-0 sm:w-[684px] sm-px-2" width="100%">
              <tr>
                <td>
                  <div class="shadow-xl border border-border-secondary rounded-lg overflow-hidden">
                    <div class="space-y-2 bg-primary-foreground p-4"><% if content_for?(:header) %>
                        <%= yield :header %>
                      <% else %>
                        <%= hosted_image_tag('mailer/header-logo.png', class: 'h-[35px] block mb-3') %>
                      <% end %>
                      <%= yield %>
                    </div>
                    <div class="p-4 bg-primary-foreground text-center border-t border-border-secondary">
                      <%= hosted_image_tag('mailer/footer-logo.png', class: 'h-[48px] mb-1') %>
                      <p class="text-muted-foreground text-sm leading-5">
                        &copy;<%= Time.current.year %> - NoScrubs Inc, All rights reserved.
                        <br />
                        1107 S 8th St, Austin, TX, USA 78704
                        <br />
                        <a href="mailto:support@noscrubs.com">Contact Support</a> | <a href="https://noscrubs.com/terms">Terms of Service</a> | <a href="https://noscrubs.com/privacy">Privacy Policy</a>
                      </p>
                    </div>
                  </div>
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td height="32"></td>
        </tr>
      </table>
    </div>
  </body>
</html>

Output:

<!DOCTYPE html>

<html
  xmlns:v="urn:schemas-microsoft-com:vml"
  xmlns:o="urn:schemas-microsoft-com:office:office"
  data-theme="light"
>
  <head>
    <meta charset="utf-8">

    <meta http-equiv="x-ua-compatible" content="ie=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta
      name="format-detection"
      content="telephone=no, date=no, address=no, email=no, url=no"
    >

    <meta name="x-apple-disable-message-reformatting">

    <title><%= message.subject %> | NoScrubs</title>

    <%= stylesheet_link_tag "mailer", media: "all" %>
    <style>
    </style>

    <style>
    </style>
  </head>
  <body style="font-family: 'DM Sans', Arial, sans-serif;">
    <% if content_for?(:preheader) %>
      <div class="hidden"><%= yield :preheader %></div>
    <% end %>
    <div
      role="article"
      aria-roledescription="email"
      aria-label="<%= message.subject %>"
      lang="en"
    >
      <table
        border="0"
        cellpadding="0"
        cellspacing="0"
        width="100%"
        class="bg-background leading-normal text-base"
      >
        <tr>
          <td height="32"></td>
        </tr>
        <tr>
          <td align="center">
            <table
              border="0"
              cellpadding="0"
              cellspacing="0"
              class="w-full max-w-[684px] px-0 sm:w-[684px] sm-px-2"
              width="100%"
            >
              <tr>
                <td>
                  <div
                    class="
                      shadow-xl border border-border-secondary rounded-lg
                      overflow-hidden
                    "
                  >
                    <div class="space-y-2 bg-primary-foreground p-4">
                      <% if content_for?(:header) %>
                        <%= yield :header %>
                      <% else %>
                        <%= hosted_image_tag('mailer/header-logo.png', class: 'h-[35px] block mb-3') %>
                      <% end %>
                      <%= yield %>
                    </div>
                    <div
                      class="
                        p-4 bg-primary-foreground text-center border-t
                        border-border-secondary
                      "
                    >
                      <%= hosted_image_tag('mailer/footer-logo.png', class: 'h-[48px] mb-1') %>
                      <p class="text-muted-foreground text-sm leading-5">
                        &copy;<%= Time.current.year %> - NoScrubs Inc, All rights reserved.
                        <br />
                        1107 S 8th St, Austin, TX, USA 78704
                        <br />
                        &copy;
                        <%= Time.current.year %>
                        - NoScrubs Inc, All rights reserved.
                        <br />
                        1107 S 8th St, Austin, TX, USA 78704
                        <br />
                        <a href="mailto:support@noscrubs.com">Contact Support</a>
                        |
                        <a href="https://noscrubs.com/terms">Terms of Service</a>
                        |
                        <a href="https://noscrubs.com/privacy">Privacy Policy</a>
                      </p>
                    </div>
                  </div>
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td height="32"></td>
        </tr>
      </table>
    </div>
  </body>
</html>

Expected:

<!DOCTYPE html>

<html
  xmlns:v="urn:schemas-microsoft-com:vml"
  xmlns:o="urn:schemas-microsoft-com:office:office"
  data-theme="light"
>
  <head>
    <meta charset="utf-8">

    <meta http-equiv="x-ua-compatible" content="ie=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta
      name="format-detection"
      content="telephone=no, date=no, address=no, email=no, url=no"
    >

    <meta name="x-apple-disable-message-reformatting">

    <title><%= message.subject %> | NoScrubs</title>

    <%= stylesheet_link_tag "mailer", media: "all" %>
    <style>
    </style>

    <style>
    </style>
  </head>
  <body style="font-family: 'DM Sans', Arial, sans-serif;">
    <% if content_for?(:preheader) %>
      <div class="hidden"><%= yield :preheader %></div>
    <% end %>
    <div
      role="article"
      aria-roledescription="email"
      aria-label="<%= message.subject %>"
      lang="en"
    >
      <table
        border="0"
        cellpadding="0"
        cellspacing="0"
        width="100%"
        class="bg-background leading-normal text-base"
      >
        <tr>
          <td height="32"></td>
        </tr>
        <tr>
          <td align="center">
            <table
              border="0"
              cellpadding="0"
              cellspacing="0"
              class="w-full max-w-[684px] px-0 sm:w-[684px] sm-px-2"
              width="100%"
            >
              <tr>
                <td>
                  <div
                    class="
                      shadow-xl border border-border-secondary rounded-lg
                      overflow-hidden
                    "
                  >
                    <div class="space-y-2 bg-primary-foreground p-4">
                      <% if content_for?(:header) %>
                        <%= yield :header %>
                      <% else %>
                        <%= hosted_image_tag('mailer/header-logo.png', class: 'h-[35px] block mb-3') %>
                      <% end %>
                      <%= yield %>
                    </div>
                    <div
                      class="
                        p-4 bg-primary-foreground text-center border-t
                        border-border-secondary
                      "
                    >
                      <%= hosted_image_tag('mailer/footer-logo.png', class: 'h-[48px] mb-1') %>
                      <p class="text-muted-foreground text-sm leading-5">
                        &copy;<%= Time.current.year %> - NoScrubs Inc, All rights reserved.
                        <br />
                        1107 S 8th St, Austin, TX, USA 78704
                        <br />
                        <a href="mailto:support@noscrubs.com">Contact Support</a>
                        |
                        <a href="https://noscrubs.com/terms">Terms of Service</a>
                        |
                        <a href="https://noscrubs.com/privacy">Privacy Policy</a>
                      </p>
                    </div>
                  </div>
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td height="32"></td>
        </tr>
      </table>
    </div>
  </body>
</html>

Playground:
Playground

Additional context:
Removing the first br (line 55) seems to fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions