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

Transform trailing whitespace to recommended way #418

Merged
merged 8 commits into from
Oct 29, 2022

Conversation

jwerre
Copy link
Contributor

@jwerre jwerre commented Oct 21, 2022

Created test to deal with issue #417

The following pug:

p Aliquam pulvinar enim eu enim finibus euismod. 
	| a(href="https://example.com") Link
	|  Suspendisse suscipit nunc non mauris sodales elementum.

should reformat to:

p Aliquam pulvinar enim eu enim finibus euismod.
	|
	| a(href="https://example.com") Link
	|
	| Suspendisse suscipit nunc non mauris sodales elementum.

@Shinigami92 Shinigami92 changed the title Added test to deal with whitespace in the recommended way. Transform trailing whitespace to recommended way Oct 23, 2022
@Shinigami92 Shinigami92 added the type: bug Functionality that does not work as intended/expected label Oct 23, 2022
Shinigami92
Shinigami92 previously approved these changes Oct 24, 2022
@Shinigami92
Copy link
Member

@serferdinand2 and @jwerre Please check the test files and tell me if I can add any more complex example
I already found a special case for nested tags, so everything can help and safes me from releasing an additional release after the bug fix

@jwerre
Copy link
Contributor Author

jwerre commented Oct 24, 2022

@Shinigami92 I took a look at your formatted.pug file and it looks like the formatting is incorrect. The anchor tag should not have a pipe in front of it. For example:

Instead of

p Aliquam pulvinar enim eu enim finibus euismod.
  |
  | a(href="https://example.com") Link
  |
  | Suspendisse suscipit nunc non mauris sodales elementum.

div
  p Aliquam pulvinar enim eu enim finibus euismod.
  p Aliquam pulvinar enim eu enim finibus euismod.
    |
    | a(href="https://example.com") Link
    |
    | Suspendisse suscipit nunc non mauris sodales elementum.

It should be:

p Aliquam pulvinar enim eu enim finibus euismod.
  |
  a(href="https://example.com") Link
  |
  | Suspendisse suscipit nunc non mauris sodales elementum.

div
  p Aliquam pulvinar enim eu enim finibus euismod.
  p Aliquam pulvinar enim eu enim finibus euismod.
    |
    a(href="https://example.com") Link
    |
    | Suspendisse suscipit nunc non mauris sodales elementum.

I think that was mistake I made and you just copy and pasted it.

@Shinigami92
Copy link
Member

@jwerre good catch 👍
Luckily it didn't changed anything as if it already reaches the a-tag, the fix is already processed

@jwerre
Copy link
Contributor Author

jwerre commented Oct 25, 2022

@Shinigami92, I Think there may be a few more outliers.

  1. You may not want spaces around other inline tags
  2. You do not want spaces where the lines ends in a period
p 
  | You put the em
  em pha
  | sis on the wrong syl
  em lable
  | .

As you currently have it I think the result will end up like this:

p 
  | You put the em
  |
  em pha
  |
  | sis on the wrong syl
  |
  em lable
  | 
  | .

OUTPUT: You put the em pha sis on the wrong syl lable .
The above has spaces around the em tags and before the period

EXPECTED: You put the emphasis on the wrong syllable.

@Shinigami92
Copy link
Member

Will add that tomorrow as a test (if you not already did as you have access to your own PR 😉)
But I don't think it will fail, as the text lines are not ending with a trailing whitespace
Only if empty whitespaces are at trailing ends, the formatter will add these additional pipes

@jwerre
Copy link
Contributor Author

jwerre commented Oct 25, 2022

Only if empty whitespaces are at trailing ends, the formatter will add these additional pipes

Ahhh... ok. I'll take your word for it.

@Shinigami92 Shinigami92 merged commit aed6523 into prettier:main Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Upon running prettier on PUG files space before and after 'a' tag disappear
2 participants