Skip to content

Conversation

@andersk
Copy link
Contributor

@andersk andersk commented Aug 21, 2021

Description

Fixes #11372.

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

Fixes prettier#11372.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
@ghost
Copy link

ghost commented May 1, 2022

This is very helpful for two reasons. Not only the fact it makes mdfiles easier to see, but also it works well with markdownlint, since markdownlint will consider inline code-blocks as usual line-length.

Hope this gets merged soon.

@andersk andersk mentioned this pull request Jul 20, 2022
23 tasks
@thorn0 thorn0 self-requested a review September 6, 2022 22:40
@andersk
Copy link
Contributor Author

andersk commented Sep 21, 2022

Still waiting for a maintainer to look at this very simple bug fix (3 lines plus tests).

Here’s a sample from the actual buggy change that Prettier wanted to apply to the Zulip documentation, which motivated this fix. Before:

(The `--config pull.rebase` option configures Git so that `git pull`
will behave like `git pull --rebase` by default.  Using `git pull
--rebase` to update your changes to resolve merge conflicts is
expected by essentially all of open source projects, including Zulip.
You can also set that option after cloning using `git config --add
pull.rebase true`, or just be careful to always run `git pull
--rebase`, never `git pull`).

Prettier 2.7.1:

(The `--config pull.rebase` option configures Git so that `git pull`
will behave like `git pull --rebase` by default. Using `git pull --rebase` to update your changes to resolve merge conflicts is
expected by essentially all of open source projects, including Zulip.
You can also set that option after cloning using `git config --add pull.rebase true`, or just be careful to always run `git pull --rebase`, never `git pull`).

With this fix:

(The `--config pull.rebase` option configures Git so that `git pull`
will behave like `git pull --rebase` by default.  Using `git pull
--rebase` to update your changes to resolve merge conflicts is
expected by essentially all of open source projects, including Zulip.
You can also set that option after cloning using `git config --add
pull.rebase true`, or just be careful to always run `git pull
--rebase`, never `git pull`).

There should be no backwards compatibility concern because the buggy formatting will be preserved if it was already applied.

@thorn0
Copy link
Member

thorn0 commented Sep 22, 2022

return { ...node, value: node.value.replace(/\s+/g, " ") };

Turns out this replacement isn't correct at all. See #13485 (comment)
Your fix is correct, but it fixes only a special case of the incorrect behavior.
Could you also fix this regexp for the proseWrap !== 'preserve' case and reflect that in the changelog?

Copy link
Member

@thorn0 thorn0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do #11373 (comment) in another PR

Copy link
Member

@fisker fisker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never saw this PR in my inbox..

Let's merge this separately, no need wait for #13590

@thorn0
Copy link
Member

thorn0 commented Oct 9, 2022

Okay, but there will be a conflict.

@thorn0 thorn0 merged commit f38111f into prettier:main Oct 9, 2022
@kachkaev
Copy link
Member

kachkaev commented Oct 9, 2022

Thanks @andersk! I’ve incorporated your change into #13590 👍

@andersk andersk deleted the inline-code-wrap branch October 10, 2022 10:52
@kachkaev kachkaev added this to the 2.8 milestone Nov 16, 2022
medikoo pushed a commit to medikoo/prettier-elastic that referenced this pull request Jan 4, 2024
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 this pull request may close these issues.

--prose-wrap=preserve should preserve line breaks in Markdown inline code spans

4 participants