-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Vue: Fix format on self-closing and empty blocks #9055
Conversation
DO you guys think this is bug? Prettier 2.1.0 --parser vue Input: <custom lang="markdown"></custom> Output: <custom lang="markdown">
</custom>
|
Yes, looks unexpected. |
I agree with thorn0 |
tests/vue/multiparser/jsfmt.spec.js
Outdated
}, | ||
{ | ||
name: "non-space", | ||
code: '<custom lang="markdown">\n \u2005 \n</custom>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one, html think it's not empty, and markdown
will print to a empty Doc
, how do I tell it's empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only child node is text consisting of whitespace only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{
"type": "concat",
"parts": [
{
"type": "concat",
"parts": [
{
"type": "fill",
"parts": []
}
]
}
]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try using normalizeParts
from doc-utils
. You might want to improve it to handle an empty fill
doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the embed parser return ifBreak('foo', '')
, we should not be able to know it's empty or not. Am I right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we first check if the content of the tag is empty or whitespace-only and skip the embedded parser if it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried, and it works, just feel something not right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to assume that reformatting an empty document should result in an empty document for any language.
f976c33
to
b44f7e0
Compare
1ea7d95
to
d987146
Compare
Done |
#9052 (comment)
docs/
directory)changelog_unreleased/*/pr-XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨