Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html: Closing > put on newline #5582

Closed
SimenB opened this issue Dec 1, 2018 · 5 comments
Closed

html: Closing > put on newline #5582

SimenB opened this issue Dec 1, 2018 · 5 comments
Labels
lang:html Issues affecting HTML (and SVG but not JSX) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:question Questions and support requests. Please use Stack Overflow for them, not the issue tracker.

Comments

@SimenB
Copy link
Contributor

SimenB commented Dec 1, 2018

Prettier 1.15.3
Playground link

--parser html

Input:

<!DOCTYPE html>
<div>
  <div>
    <div>
      <div>
        <div>
          <div>
            <div>
              Response body
              <textarea
                name="readinessProbe.response.body"
              >{{ readinessProbe.response.body }}</textarea>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

Output:

<!DOCTYPE html>
<div>
  <div>
    <div>
      <div>
        <div>
          <div>
            <div>
              Response body
              <textarea name="readinessProbe.response.body">
{{ readinessProbe.response.body }}</textarea
              >
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

Expected behavior:
Not to change the input. The input comes from 1.15.2.

</textarea
>

That part is the thing I'm reporting, if the amount if divs were confusing 😅

html-whitespace-sensitivity doesn't matter, btw

@ikatyang
Copy link
Member

ikatyang commented Dec 2, 2018

Partially related to #5377, but it seems you forgot to use the angular/vue parser? which should trigger the formatting for interpolations:

Prettier 1.15.3
Playground link

--parser angular

Input:

<!DOCTYPE html>
<div>
  <div>
    <div>
      <div>
        <div>
          <div>
            <div>
              Response body
              <textarea
                name="readinessProbe.response.body"
              >{{ readinessProbe.response.body }}</textarea>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

Output:

<!DOCTYPE html>
<div>
  <div>
    <div>
      <div>
        <div>
          <div>
            <div>
              Response body
              <textarea name="readinessProbe.response.body">{{
                readinessProbe.response.body
              }}</textarea>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

@ikatyang ikatyang added the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Dec 2, 2018
@SimenB
Copy link
Contributor Author

SimenB commented Dec 2, 2018

Is it related to that? This is closing > on the closing tag, not the opening tag.

That said, we should probably use another parser, even though I'd expect the content of a textarea to just be treated as plain text in the html parser

@no-response no-response bot removed the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Dec 2, 2018
@SimenB
Copy link
Contributor Author

SimenB commented Dec 2, 2018

Feel free to close however, as changing the parser works fine 🙂

@ikatyang
Copy link
Member

ikatyang commented Dec 2, 2018

Is it related to that? This is closing > on the closing tag, not the opening tag.

Since --jsx-bracket-same-line is defined as "do not put > alone on the next line", #5377 should track it for both opening and closing tags.

That said, we should probably use another parser, even though I'd expect the content of a textarea to just be treated as plain text in the html parser

If you intend to use it as an interpolation, you should use one of the parser that supports interpolation since there's a special rule for <textarea> in the HTML spec that the first LF will be ignored in <textarea>. That said, the following formatting can be unsafe based on the value of the interpolation:

<!-- before -->
<textarea>{{something}}

<!-- after -->
<textarea>
{{something}}

It'll break the output if {{something}} is interpolated as something starts with LF since there will be two LF and only the first one will be ignored, causes an extra LF.

And also, continuous whitespaces in <textarea> can not be collapsed but it's not the case for interpolations.

@ikatyang ikatyang added the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Dec 2, 2018
@SimenB
Copy link
Contributor Author

SimenB commented Dec 3, 2018

Ah, alright! You learn something every day 🙂 Thanks for the detailed response

@SimenB SimenB closed this as completed Dec 3, 2018
@no-response no-response bot removed the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Dec 3, 2018
@ikatyang ikatyang added type:question Questions and support requests. Please use Stack Overflow for them, not the issue tracker. lang:html Issues affecting HTML (and SVG but not JSX) labels Dec 3, 2018
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Mar 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:html Issues affecting HTML (and SVG but not JSX) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:question Questions and support requests. Please use Stack Overflow for them, not the issue tracker.
Projects
None yet
Development

No branches or pull requests

2 participants