question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configure whitespace-sensitive tags

See original GitHub issue

Related 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:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
ourwaycommented, Sep 13, 2019

It is a major issue for me write now, I am not able to format the code without breaking typography and other elements.

1reaction
dummdidummcommented, Feb 8, 2021

The pre-issue was fixed a while ago. Since prettier-plugin-svelte version 2.0.0, only known block elements such as div or p are formatted as whitespace-insensitive. Since 2.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 that CodeSnippet case), use <!-- prettier-ignore -->. These options are enough to tweak the setup as desired, therefore I’m going to close this issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found