-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Print HTML5 doctype in lowercase
#7391
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
Conversation
79d16df to
ca3918c
Compare
|
I'm down! |
|
It would be another incompatibility with XML. Why introduce it without a reason? |
|
xml requires uppercase? |
|
I think we should discuss about supporting xhtml (xml) |
|
How about lowercasing it only if it's the HTML5 doctype ( |
|
@thorn0 Problem what some developers can use not fully html template (without doctype) and we can potential break code |
|
I mean lowercasing only in this one case, when doctype is As far as I understand, But also there is (or was, it's "no longer in active maintenance") a thing called Polyglot markup, a way to write markup compatible with both syntaxes at the same time, and it requires the doctype to be uppercase. So after all, the safest option seems to be to keep the current behavior. |
e8ffaac to
b805565
Compare
|
I understand the concerns about merging this as is. This is the explicit change of the current behaviour. |
8e4b65b to
9781cfc
Compare
|
@kydesnic We don't add options. |
9781cfc to
2cc228c
Compare
|
Can we include this in V3? |
JounQin
left a comment
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.
AFAIK, prettier does not change the inputs but only prints, why it is changed here?
We change html tags to lowercase.
Check original issue #6502 |
So the correct change to me should be keeping the input as-is instead. |
|
@fisker It seems you disagree with my opinion here which follows https://prettier.io/docs/en/rationale.html#what-prettier-is-_not_-concerned-about and it is mentioned a lot of times by @thorn0 elsewhere. Maybe I ask why we are not consistent here? |
|
I don't talk. |
|
Prettier usually normalizes case-insensitive things: CSS property names, HTML tag names, JS hex numbers, etc. Often it's done by the parser. When something is syntactically case-insensitive, it means case is styling/formatting, which is what Prettier deals with. Of course, there aren't strict definitions of what "formatting", "linting", "transform", etc. are, so the debates about this stuff can be endless. |
It makes sense to me. And then can we define what are considering as formatting into the policy on prettier's side in details? Otherwise it could still be confusing in the future. For example, when the content is case-insensitive we usually print them in lowercase. |
I don't believe it's possible to come up with clear and satisfying definitions. It's all too complicated and full of tradeoffs. E.g., what are numeric separators in JS? Syntax or formatting? Are the two ways to make a code block in Markdown (fenced and indented) just two different styles for the same syntactic thing, so they should be normalized to one style? What about empty statements in JS? The general idea is kind of simple: "preserve the syntax and regenerate formatting from scratch (keeping some elements of the original formatting when practical)", but when it comes to defining the line between syntax and formatting, things become tricky. I don't think this boundary is formalizable. Decisions should be made on the case-by-case basis. 🤷♂️
I'd say it gets confusing mostly in bikesheddy cases like this doctype issue, where the practical value of doing it one way or another is really questionable. |
|
#15096 Personally I want it to stay uppercase regardless of the standard, how do I control it from being converted to lowercase by prettier? Its performance in prettier 2.x is in line with my expectations, but recently I upgraded to 3.0 and it is not |
|
DOCTYPE is case sensitive in XML contexts. With this change, prettier no longer supports my XHTML. |
Browsers care about the doctype case in XML contexts.
The 'polyglot' markup is and has been supported by all major browser engines (even Trident & EdgeHTML) for over a decade. It has use in some sites and frameworks (including many of my own). |
|
Polyglot markup, doctype doc https://www.w3.org/TR/html-polyglot/#doctype Uppercase needed. |
|
Are W3C standards a joke to you? If something works, why would you ever want to ruin it? Revert the changes concerning the |
|
DOCTYPE is not an HTML tag. It's a preamble. "We lowercase all HTML tags" shouldn't have applied here. |
|
How to change that behavior? |
my proposal to add |
This is the intended behavior of Prettier (for some reason): <prettier/prettier#7391> This reverts commit b83e774.
Please DO NOT MERGE until we have consensus that this should be accepted.
Fixes: #6502
docs/directory)changelog_unreleased/*/pr-XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.✨Try the playground for this PR✨