Thanks to visit codestin.com
Credit goes to github.com

Skip to content

πŸ› Unexpected formatting of whitespace in HTML after inline elements within textΒ #7960

@jamesgeorgewilliams

Description

@jamesgeorgewilliams

Environment information

CLI:
  Version:                      2.3.2
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  BIOME_THREADS:                unset
  NO_COLOR:                     unset
  TERM:                         xterm-ghostty
  JS_RUNTIME_VERSION:           v22.12.0
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         pnpm/10.6.5

Biome Configuration:
  Status:                       Loaded successfully
  Path:                         biome.json
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  true

Workspace:
  Open Documents:               0

What happened?

  1. Unexpected result of formatting space in html / html-ish files. Whitespace is removed after inline elements within a <p> tag when "whitespaceSensitivity": "strict" is enabled.

Playground

<p>
	Lorem, ipsum dolor sit amet <span>consectetur</span> adipisicing elit.
</p>

<!--
	Moving subsequent text to newline preserves whitespace.
-->
<p>
	Lorem, ipsum dolor sit amet <span>consectetur</span>
	adipisicing elit.
</p>
  1. The following output is observed for the 1st case above. Whitespace is removed after the closing tag.
<p>
	Lorem, ipsum dolor sit amet <span>consectetur</span>adipisicing elit.
</p>
// biome.json

{
  "$schema": "https://biomejs.dev/schemas/2.3.2/schema.json",
  "html": {
    "experimentalFullSupportEnabled": true,
    "formatter": {
      "enabled": true,
      "indentScriptAndStyle": true,
      "whitespaceSensitivity": "strict"
    }
  },
}

Expected result

Expected formatting with strict whitespaceSensitivity:

<p>
	Lorem, ipsum dolor sit amet <span>consectetur</span> adipisicing elit.
</p>

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-FormatterArea: formatterL-HTMLLanguage: HTML and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bug

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions