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
Prettier is removing the doctype from handlebar files #11223
Comments
|
I cannot reproduce this in playground. Can you reproduce in playground? Prettier 2.3.2 --parser htmlInput: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>Output: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body></body>
</html> |
|
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further. |
|
Sorry. This happened when formatting a .handlebars file. The file was located at /views/layouts/main.handlebars. On further testing, it seems to be a problem .handlebars files, and not .html files. Still a critical bug. |
|
Thanks! Prettier 2.3.2 --parser glimmerInput: <!DOCTYPE html>
<html lang="en">
</html>Output: <html lang="en">
</html>It seems a known issue in parser. glimmerjs/glimmer-vm#870 |
…from commit hook There is a huge bug with the `glimmer` library (which prettier relies on for parsing) where the <!DOCTYPE html> tag will get dropped improperly when formatting. I'm replacing the tags and keeping the formatted files here but removing the auto-format settings from commit hooks. See more: prettier/prettier#11223
* chore(package): update husky@7 * chore(actions): optimize update-translations install * chore(package): bump commitlint@13.1.0 * chore: remove extraneous npm messages * chore(package): update lint-staged@11.1.2 * chore(package): bump prettier@2.3.2 * chore(templates): clean up with prettier * chore(package): bump stylelint deps * fix(view): plausible domain var * fix(prettier): keep formatted hbs for now, but remove hbs formatting from commit hook There is a huge bug with the `glimmer` library (which prettier relies on for parsing) where the <!DOCTYPE html> tag will get dropped improperly when formatting. I'm replacing the tags and keeping the formatted files here but removing the auto-format settings from commit hooks. See more: prettier/prettier#11223
|
Seems still to be an issue after the official release of handlebars support and glimmerjs fixing the issue? |
|
According to glimmerjs/glimmer-vm#870, the issues have already been fixed in glimmerjs/glimmer-vm#1305. However, I'm experiencing the same issues with v2.7.1. |
|
I found this issue on https://ovio.org/projects and would love to contribute! |
|
Go ahead! |
|
I tried to work on this, but it seems the doctype info still missing in AST. > require('@glimmer/syntax').preprocess('<!DOCTYPE html>')
{
type: 'Template',
body: [],
blockParams: [],
loc: SourceSpan {
data: HbsSpan {
source: [Source],
hbsPositions: [Object],
kind: 'HbsPosition',
_charPosSpan: null,
_providedHbsLoc: [Object]
},
isInvisible: false
}
} |
|
This happens to .astro files too. |
However, due to prettier/prettier#11223, we don't always run Prettier on the handlebars file. Only manually and we add back `<!DOCTYPE html>` to the template.
|
On, VS Code the following .prettierrc works {
"overrides": [
{
"files": "*.handlebars",
"options": {
"parser": "html"
}
}
]
} |
Prettier does not depend on text editor. I tested it on prettier v2.8.8 and it works. Thanks. Here's my config in overrides = [
{ files = "*.hbs", options = { parser = "html" } }
] |
Environments:
Steps to reproduce:
Original code:
Formatted code:
Expected behavior:
The
<!DOCTYPE html>should be preserved unchanged.Actual behavior:
The
<!DOCTYPE html>is removed.The text was updated successfully, but these errors were encountered: