docs on whitespace sensitivity: better wording (#6699)
parent
63b450b8e6
commit
2c14a7f13c
|
@ -37,7 +37,7 @@ As you may notice during daily HTML works, the following two cases won't produce
|
|||
| with spaces | `1<b> 2 </b>3` | 1<b> 2 </b>3 |
|
||||
| without spaces | `1<b>2</b>3` | 1<b>2</b>3 |
|
||||
|
||||
This is because whitespaces are sensitive in inline elements.
|
||||
This happens because whitespace is significant in inline elements.
|
||||
|
||||
For this reason, we cannot safely format
|
||||
|
||||
|
@ -59,8 +59,8 @@ since it may modify the displayed output in the browser.
|
|||
|
||||
Instead of breaking your code or just doing nothing, we introduce _whitespace-sensitive formatting_, which:
|
||||
|
||||
- follows the default CSS `display` value for every element to identify if the whitespace is sensitive,
|
||||
- and borrows the opening or closing tags (if necessary) to avoid adding or removing sensitive whitespaces.
|
||||
- follows the default CSS `display` value for every element to identify if the whitespace inside it is significant,
|
||||
- and wraps the tags in such a way as to avoid adding or removing significant whitespace.
|
||||
|
||||
For example:
|
||||
|
||||
|
@ -81,7 +81,7 @@ For example:
|
|||
</div>
|
||||
```
|
||||
|
||||
We also allow magic comments (e.g., `<!-- display: block -->`) to tell Prettier how to format this element
|
||||
We also allow magic comments (e.g., `<!-- display: block -->`) to tell Prettier how to format elements
|
||||
due to the fact that CSS display can be changed:
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
|
@ -98,13 +98,13 @@ due to the fact that CSS display can be changed:
|
|||
```
|
||||
|
||||
There's also an option for the global whitespace sensitivity
|
||||
in case you may want maximum safety or you just don't care about those whitespaces:
|
||||
in case you may want maximum safety or you just don't care about that whitespace:
|
||||
|
||||
`--html-whitespace-sensitivity` (defaults to `css`)
|
||||
|
||||
- `css` - Respect the default value of CSS `display` property.
|
||||
- `strict` - Whitespaces are considered sensitive.
|
||||
- `ignore` - Whitespaces are considered insensitive.
|
||||
- `strict` - All whitespace is considered significant.
|
||||
- `ignore` - All whitespace is considered insignificant.
|
||||
|
||||
##### Automatic parser inference
|
||||
|
||||
|
|
Loading…
Reference in New Issue