Small glitch (heh heh) in code formater

Notice the /label tag

<td>
                  <label for="City"><b>City *</b></label
                  ><br />
                  <input
                    id="City"
                    name="City"
                    type="text"
                    value=""
                    maxlength="50"
                    style="width: 340px"
                  />
                </td>
                <td>
                  <label for="ST"><b>ST *</b></label
                  ><br />
                  <input
                    id="ST"
                    name="ST"
                    type="text"
                    value=""
                    maxlength="50"
                    style="width: 80px"
                  />
                </td>
                <td>
                  <label for="ZIP"><b>ZIP *</b></label
                  ><br />
                  <input
                    id="ZIP"
                    name="ZIP"
                    type="text"
                    value=""
                    maxlength="50"
                    style="width: 80px"
                  />
                </td>

Hi @odysseus55, welcome to the Glitch forum!

I think this is a result of how prettier itself deals with HTML’s whitespace rules. You can take a look at https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting to see the logic they use. I think if you add a .prettierrc file to your project with contents like

{
  "htmlWhitespaceSensitivity": "ignore"
}

you might have better luck, or formatting your labels like

<label for="City">
   <b>City *</b>
</label>
<br />

would make prettier ignore those lines for this formatting rule.

Since prettier support is pretty new we’re still discussing what the best set of default options would be, so there may be changes around some of these settings as time goes on.

Sorry for the bother!

1 Like