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

Markdown undesirable formatting behaviour when new text added to paragraph #16223

Open
ncasdpo opened this issue Apr 15, 2024 · 3 comments
Open
Labels
status:awaiting response Issues that require answers to questions from maintainers before action can be taken

Comments

@ncasdpo
Copy link

ncasdpo commented Apr 15, 2024

In a markdown file, if you have written out a new single line of text, the lorem ipsum paragraph in the recorded example, the formatting is fine.

But when you add text into the middle of the paragraph, the line breaks from the initial formatting will be kept instead of reformatting the whole paragraph again. Please see the screen recording here:
https://github.com/prettier/prettier/assets/153771236/6fd827b2-2e20-47df-88a0-2a62381ca0d2

@sosukesuzuki
Copy link
Member

Can follow the issue template?

@ncasdpo
Copy link
Author

ncasdpo commented May 1, 2024

Hi @sosukesuzuki. Sorry about that, I did try to use the playground to reproduce the error, but I couldn't see how to format the file. I don't know if the formatting is supposed to happen automatically? I pasted in some dummy text and I set the print width to 60 but nothing happened. I have attached a screenshot showing this.

image

@kachkaev
Copy link
Member

I did try to use the playground to reproduce the error, but I couldn't see how to format the file.

@ncasdpo you need to set --prose-wrap in the Playground:






Here is what I tried:

Initial formatting

Prettier 3.2.5
Playground link

--parser markdown
--prose-wrap always

Input:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Output:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

Edit in the middle of the paragrpah

I copied the result into the left column and added a few asdfs on line 3:

Prettier 3.2.5
Playground link

--parser markdown
--prose-wrap always

Input:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

Output:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis asdf
asdf asdf asdf asdf asdf asdf asdf asdf asdf nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.

The result looks correct.

Can you please check if you are using Prettier in your editor or if it’s some other formatter that you run there? Prettier should behave the same way as in the Playground.

@kachkaev kachkaev added the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:awaiting response Issues that require answers to questions from maintainers before action can be taken
Projects
None yet
Development

No branches or pull requests

3 participants