Skip to content

Bug: Trailing space incorrect behavior #524

Open
@Lutymane

Description

@Lutymane

Plugin Version

3.2.0

Prettier Version

3.3.3

Which frameworks are affected?

  • none
  • vue
  • angular
  • svelte

Node Version

21.7.2

Which operating systems have you used?

  • Linux
  • macOS
  • Windows

Prettier config

export default {
  plugins: ["@prettier/plugin-pug"],

  htmlWhitespaceSensitivity: "css",
  printWidth: 80,
  arrowParens: "avoid",
  bracketSameLine: false,
  semi: true,
  tabWidth: 2,
  useTabs: false,
  endOfLine: "auto",
  trailingComma: "es5",
  vueIndentScriptAndStyle: false,

  pugAttributeSeparator: "as-needed",
  pugFramework: "vue",
};

Input

h2 Link: 
  a(href="") Click

note trailing space "Link: "

Output or Error

h2 Link:
  |
  a(href="") Click

note trailing space is removed "Link:" and pipe doesn't have it either!

Expected Output

h2 Link:
  | 
  a(href="") Click

//- or perhaps 
h2
  | Link:
  |
  a(href=“”) Click

note trailing space after pipe "| " - the intended behavior

OR

Probably better move the text into child pipe and insert an extra pipe for that space

Additional Context

Prettier alters the result of the template which is not intended. Please look at https://pugjs.org/language/plain-text.html#whitespace-control

Also it doesn't respect htmlWhitespaceSensitivity: "strict" option and still removes any extra whitespace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions