Vue: Fix format on self-closing and empty blocks#9055
Vue: Fix format on self-closing and empty blocks#9055fisker merged 7 commits intoprettier:masterfrom
Conversation
|
DO you guys think this is bug? Prettier 2.1.0 --parser vueInput: <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.
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.
The only child node is text consisting of whitespace only.
There was a problem hiding this comment.
{
"type": "concat",
"parts": [
{
"type": "concat",
"parts": [
{
"type": "fill",
"parts": []
}
]
}
]
}There was a problem hiding this comment.
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.
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.
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.
I tried, and it works, just feel something not right.
There was a problem hiding this comment.
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.mdfile followingchangelog_unreleased/TEMPLATE.md.✨Try the playground for this PR✨