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

Closing tag is split for long tag names and long lines. #15432

Open
spez opened this issue Sep 19, 2023 · 4 comments · May be fixed by #15967
Open

Closing tag is split for long tag names and long lines. #15432

spez opened this issue Sep 19, 2023 · 4 comments · May be fixed by #15967
Labels
lang:html Issues affecting HTML (and SVG but not JSX) type:bug Issues identifying ugly output, or a defect in the program

Comments

@spez
Copy link

spez commented Sep 19, 2023

Prettier 3.0.3
Playground link

--parser html

Input:

<textarea id="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">foo</textarea>

Output:

<textarea id="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">
foo</textarea
>

Expected behavior:

<textarea id="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">
  foo
</textarea>

If I replace the <textarea> with a <div>, it works as expected.

@sosukesuzuki sosukesuzuki added type:bug Issues identifying ugly output, or a defect in the program lang:html Issues affecting HTML (and SVG but not JSX) labels Sep 20, 2023
@vivekjoshi556
Copy link
Contributor

Should it be formatting textarea at all?
Formatting will lead to changing the actual content that will be displayed inside the textarea.

@t-mangoe
Copy link
Contributor

t-mangoe commented Dec 9, 2023

I have looked into this issue.
The printClosingTagSuffix function was outputting part of the closing tag (</textarea).
When needsToBorrowParentClosingTagStartMarker function is called to foo, the function seems to return True.

function printClosingTagSuffix(node, options) {
return needsToBorrowParentClosingTagStartMarker(node)
? printClosingTagStartMarker(node.parent, options)
: needsToBorrowNextOpeningTagStartMarker(node)
? printOpeningTagStartMarker(node.next)
: "";
}

@t-mangoe
Copy link
Contributor

I have modified the code to try it out.
I am going to send a Pull Request. I would be happy for you to check my code.

@t-mangoe t-mangoe linked a pull request Jan 20, 2024 that will close this issue
4 tasks
@jacobtylerwalls
Copy link

Also affects the <span> tag:
playground

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang:html Issues affecting HTML (and SVG but not JSX) type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants