[HTML] Format values of attributes with defined semantics #5482
Labels
lang:html
Issues affecting HTML (and SVG but not JSX)
type:enhancement
A potential new feature to be added, or an improvement to how we print something
As briefly discussed in #5479, this issue targets the formatting of HTML attribute values that have defined semantics: for example, in regard to white spaces or commas.
An example of such an attribute is
class
, whereclass=" a b c "
should be semantically equivalent toclass="a b c"
. However, note that if the user is parsingelement.className
directly, this change is not safe. This could be controller via--html-whitespace-sensitivity
or a new flag.Solving this issue would first require some research effort into finding out which HTML attributes have values with semantics that allow Prettier to manipulate them. A list of all (most?) HTML attributes can be found at: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
Implementation note: some attribute semantics are bound to the HTML element they are part of, e.g. the semantics of
name
are different between abutton
element and ameta
element;class
is a global attribute, so its semantics should be valid for all elements.Prettier 1.15.2
Playground link
Input (
class
,content
, andaccept
examples):Output (
class
,content
, andaccept
examples):Expected behavior (
class
,content
, andaccept
examples):The text was updated successfully, but these errors were encountered: