Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unwanted white-space surrounding inline elements #7

Merged
merged 1 commit into from Nov 9, 2023

Conversation

Roboe
Copy link
Contributor

@Roboe Roboe commented Oct 22, 2023

This only happens with the pretty option.

Before this:

<p>
  JSX (
  <strong>JavaScript Syntax Extension</strong>
  )
</p>

After this:

<p
    >JSX (<strong>JavaScript Syntax Extension</strong>)
</p
    >

Prettier docs: https://prettier.io/docs/en/options.html#html-whitespace-sensitivity

This only happens with the `pretty` option.

Before this:

    <p>
        JSX (
        <strong>JavaScript Syntax Extension</strong>
        )
    </p>

After this:

    <p
        >JSX (<strong>JavaScript Syntax Extension</strong>)
    </p
        >

Prettier docs: https://prettier.io/docs/en/options.html#html-whitespace-sensitivity
@dqh-au
Copy link
Contributor

dqh-au commented Nov 7, 2023

Ah, yep. Sadly this will make the output far less 'pretty' but I agree that it's the right change to make.

@Roboe
Copy link
Contributor Author

Roboe commented Nov 9, 2023

Sure. At least it's still quite readable, though. But more importantly, it won't make you crazy debugging whitespace issues, 😂

@dqh-au dqh-au merged commit 3a6de69 into NakedJSX:main Nov 9, 2023
@dqh-au
Copy link
Contributor

dqh-au commented Nov 9, 2023

I'm curious - why are you using the option? It's mostly there for generating the documentation, for which I'll now have to add a new flag for the unsafe behaviour. Strict mode is quite ugly (perhaps I should keep pretty as it was and add --ugly)

@Roboe
Copy link
Contributor Author

Roboe commented Nov 11, 2023

I've using the pretty option for development builds. That way, debugging is nicer.

@dqh-au
Copy link
Contributor

dqh-au commented Mar 30, 2024

Found a bug in Prettier while looking at this!

@dqh-au
Copy link
Contributor

dqh-au commented Mar 31, 2024

So, NakedJSX 0.14.4 adds --pretty-ish which enables 'strict' whitespace mode. And --pretty now uses 'css' whitespace mode rather than 'ignore', which attempts to not alter meaningful whitespace based on the default css display property for the element type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants