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: Trailing whitespace in tags is not trimmed #425

Closed
2 of 7 tasks
ofk opened this issue Jan 4, 2023 · 5 comments · Fixed by #427
Closed
2 of 7 tasks

Bug: Trailing whitespace in tags is not trimmed #425

ofk opened this issue Jan 4, 2023 · 5 comments · Fixed by #427
Assignees

Comments

@ofk
Copy link

ofk commented Jan 4, 2023

Plugin Version

v2.3.0

Prettier Version

v2.8.1

Which frameworks are affected?

  • none
  • vue
  • angular
  • svelte

Node Version

v16.17.0

Which operating systems have you used?

  • Linux
  • macOS
  • Windows

Prettier config

{

}

Input

html
  body
    p 
      a Link

Output or Error

html
  body
    p 
      |
      a Link

Expected Output

html
  body
    p
      a Link

Additional Context

Note the mixed whitespace immediately following the p element.
The major problem with this bug is that running prettier on this output yields an even different result (more pipes).

@Shinigami92
Copy link
Member

Looks like this is a follow up issue to #417, is it?

@Shinigami92
Copy link
Member

Ah I assume the most important part here is that after the p tag is a trailing whitespace (p )
Will add a test for this later and try to fix it if I can reproduce it

@Shinigami92 Shinigami92 self-assigned this Jan 4, 2023
@Shinigami92
Copy link
Member

Shinigami92 commented Jan 5, 2023

@ofk For me the output is

html
  body
    p
      |
      a Link

and not

html
  body
    p 
      |
      a Link

So it looks like it correctly transforms the whitespace after the p tag into a |, which is documented here: https://pugjs.org/language/plain-text.html#whitespace-control

Please confirm that this could solve your issue and then close it, otherwise please explain more deeply what your issue is

@ofk ofk changed the title Bug: Bug: Trailing whitespace in tags is not trimmed Jan 13, 2023
@ofk
Copy link
Author

ofk commented Jan 13, 2023

Sorry for the late response.

Your output may be more appropriate.
The biggest problem with this input is that the result changes with each run of prettier.
Therefore, if multiple runs do not change the results, I am fine with any modification.

Input

html
  body
    p 
      a Link

First prettier output

html
  body
    p 
      |
      a Link

Second prettier output (or apply prettier to first prettier output)

html
  body
    p 
      |
      |
      a Link

Third prettier output (or apply prettier to second prettier output)

html
  body
    p 
      |
      |
      |
      a Link

@Shinigami92
Copy link
Member

@ofk AHA, that is an important info!
I need to update the test to run the formatter twice then
If I find the time, will do this this weekend 👍

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 a pull request may close this issue.

2 participants