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

🐛 BUG: HTML elements formatting differently than HTML files #375

Open
steveg152 opened this issue Oct 3, 2023 · 1 comment
Open

🐛 BUG: HTML elements formatting differently than HTML files #375

steveg152 opened this issue Oct 3, 2023 · 1 comment
Labels
- P4: important Violate documented behavior or significantly improves performance (priority)

Comments

@steveg152
Copy link

Describe the Bug

The following HTML code from a .astro file is not formatting correctly. Prettier is running and there are no errors in the extension logs, all prettier rules in the config are working in .astro files, the issue is simply the HTML structure.

Dep versions

"prettier": "^3.0.3",
"prettier-plugin-astro": "^0.12.0"

Current Formatting

 <nav>
      <ul><li>Item 1</li><li>Item 2</li></ul>
 </nav>

Expected Result

 <nav>
      <ul>
        <li>Item 1</li>
        <li>Item 2</li>
      </ul>
 </nav>

.prettierrc

{
  "semi": false,
  "singleQuote": true,
  "printWidth": 80,
  "tabWidth": 2,
  "plugins": ["prettier-plugin-astro"]
}

VS Code settings.json

"prettier.documentSelectors": ["**/*.astro"],
 "[astro]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },

Steps to Reproduce

  1. npm init astro using template
  2. ...
  3. ...
  4. ...
  5. Error! Describe what went wrong (and what was expected instead)...
@Princesseuh Princesseuh added needs triage Issue needs to be triaged - P4: important Violate documented behavior or significantly improves performance (priority) and removed needs triage Issue needs to be triaged labels Nov 28, 2023
@VoxelMC
Copy link

VoxelMC commented Feb 16, 2024

This also occurs for the following:

<!-- Observed -->
<div><div></div><div></div></div>

<!-- Expected, as they are the epitome of block-level -->
<div>
	<div></div>
	<div></div>
</div>

Perhaps it is just a caveat of block-level tags, where newline and indentation are not required by the formatter? @Princesseuh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly improves performance (priority)
Projects
None yet
Development

No branches or pull requests

3 participants