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

HTML 'strict' whitespace sometimes injecting a '>' #16184

Open
dqh-au opened this issue Mar 30, 2024 · 0 comments
Open

HTML 'strict' whitespace sometimes injecting a '>' #16184

dqh-au opened this issue Mar 30, 2024 · 0 comments
Labels
lang:html Issues affecting HTML (and SVG but not JSX) status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug

Comments

@dqh-au
Copy link

dqh-au commented Mar 30, 2024

Prettier 3.2.5
Playground link

--parser html
--html-whitespace-sensitivity strict

Input:

<p></p><pre><code></code></pre>

Output:

<p></p>><pre><code></code></pre>

Expected output:

<p></p><pre><code></code></pre>

Why?
In html strict whitespace mode, Prettier is injecting a > character between the </p> and the <pre>, but only if:

  • there is no character / newline between </p> and <pre>,
  • and there is a tag (such as <code>) within the <pre> block.

I noticed this in Prettier 2.8.8 whilst working on NakedJSX, and the issue remains in Prettier 3.2.5.

dqh-au added a commit to NakedJSX/core that referenced this issue Mar 30, 2024
@sosukesuzuki sosukesuzuki added lang:html Issues affecting HTML (and SVG but not JSX) status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug labels Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang:html Issues affecting HTML (and SVG but not JSX) status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug
Projects
None yet
Development

No branches or pull requests

2 participants