Configure whitespace-sensitive tags
See original GitHub issueRelated to #24, whitespace-sensitive tags should not be modified on format. For example, this
<pre>foo
bar baz</pre>
becomes this
<pre>foo bar baz</pre>
I would also like to be able to configure custom tags to follow the same rules as the <pre>
tag. For example, if I configure the CodeSnippet
tag to be whitespace-sensitive, this should not change after formatting:
<CodeSnippet lang="js">const foo = () => {
return 42
}</CodeSnippet>
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:10 (8 by maintainers)
Top Results From Across the Web
html-whitespace-sensitive-tag-names - npm
List of whitespace sensitive HTML tag names. Install. This package is ESM only: Node 12+ is needed to use it and it must...
Read more >white-space - CSS: Cascading Style Sheets - MDN Web Docs
The white-space CSS property sets how white space inside an element is handled.
Read more >configure Prettier to allow whitespace except within anchor tags
1. Your first snippet with div throws syntax error SyntaxError: Unexpected closing tag "body". and <a>hello</a> stays same and doesn't expand.
Read more >What You Need to Know About Whitespace in XML - Oracle
This attribute is inherited by child elements from their root element. When declared, it must be given as an enumerated type whose only...
Read more >html-whitespace-sensitive-tag-names v2.0.0 Bundlephobia
Size of html-whitespace-sensitive-tag-names v2.0.0 is 267.0 B (minified), and 205.0 B when compressed using GZIP. Bundlephobia helps you find the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It is a major issue for me write now, I am not able to format the code without breaking typography and other elements.
The
pre
-issue was fixed a while ago. Sinceprettier-plugin-svelte
version2.0.0
, only known block elements such asdiv
orp
are formatted as whitespace-insensitive. Since2.1.0
, the htmlWhitespaceSensitivity option is supported, which means you can chose yourself if you want known block elements, all or none treated as whitespace sensitive. If you want to break out of the behavior for certain tags or want to leave the contents untouched (for example in thatCodeSnippet
case), use<!-- prettier-ignore -->
. These options are enough to tweak the setup as desired, therefore I’m going to close this issue.