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 display css for custom components

See original GitHub issue

--html-whitespace-sensitivity css is nice when working with native HTML as it sets the display status properly (most of the time)

However, for custom components, it seems to always err on the side of caution and defaults to inline.

It would be nice if it were possible to set default display for custom JSX/NG/Vue? components. This would be nice for codebases where many components may be used in place of HTML elements.

Prettier 1.15.1 Playground link

--parser angular

Input:

<div>
  Something
</div>

<span>
  Something
</span>

<custom-inline>
  Something
</custom-inline>

<custom-block>
  Something Else
</custom-block>

<!-- display: block -->
<custom-block>
  Something Else
</custom-block>

<!-- it would be nice to set custom-block as "block" always -->

Output:

<div>Something</div>

<span> Something </span>

<custom-inline> Something </custom-inline>

<custom-block> Something Else </custom-block>

<!-- display: block -->
<custom-block>Something Else</custom-block>

<!-- it would be nice to set custom-block as "block" always -->

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:10
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mashpiecommented, Dec 20, 2018

There might be tons of examples on custom elements that now get treated as standard html, but should be not - not an easy task (examples on vue-i18n):

Playground vue-i18n as inline-yaml

Playground vue-i18n as inline-json

in that case it could help to specify desired lang as

<i18n lang="yaml">
en:
  welcome: Welcome!
de:
  welcome: Willkommen!
</i18n>

or

<i18n lang="json">
{
    "en": {
        "welcome": "Welcome!"
    },
    "de": {
        "welcome": "Willkommen!"
    }
}
</i18n>

still there are a few more special cases imaginable (esp. as some packages/libs might not stick to official html/css specs), which makes me think a simple --html-ignore: i18n,custom-block option is the only common workaround and maybe even fastes to implement?

// 2-cents-end

1reaction
thorn0commented, Jul 21, 2020

@evilebottnawi It’s already strict (inline) for custom (unknown) elements. So this issue is about your second step.

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Using White Space For Readability In HTML And CSS
White Space Readability Well-written, readable code doesn't create mind games and labyrinths when other developers read it.
Read more >
Fighting the Space Between Inline Block Elements | CSS-Tricks
One is to use a custom font with spaces character of zero width; should be working fine and I think we can easily...
Read more >
How to remove the space between inline/inline-block elements?
It's called a custom font with zero-width spaces, which allows you to collapse the whitespace (added by the browser for inline elements when...
Read more >
4 Easy Ways to Insert Spaces in HTML - HubSpot Blog
However, if you want to add space for styling purposes (for instance, whitespace between elements), we recommend using CSS instead — jump to ......
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