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

"proseWrap: always" breaks markdown links #9232

Open
bschlenk opened this issue Sep 18, 2020 · 5 comments
Open

"proseWrap: always" breaks markdown links #9232

bschlenk opened this issue Sep 18, 2020 · 5 comments
Labels
lang:markdown Issues affecting Markdown status:needs discussion Issues needing discussion and a decision to be made before action can be taken

Comments

@bschlenk
Copy link
Contributor

Prettier 2.1.2
Playground link

--parser markdown
--prose-wrap always

Input:

Check out [this link]

[this link]: https://this-is-a-really-long-url-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com

Output:

Check out [this link]

[this link]:
  https://this-is-a-really-long-url-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com

Expected behavior:

I guess this is the currently expected behavior, but it breaks the markdown formatter my company uses - the link renders as a literal [this link], and you can still see the link text at the bottom of the document. Without the newline, the link renders as expected. I'd prefer not to disable proseWrap because I do prefer my markdown to wrap at 80 characters. But I wouldn't necessarily consider the links at the bottom to be a part of the "prose" of the document, so maybe they can be exempt from this setting and always format as one line?

@alexander-akait alexander-akait added lang:markdown Issues affecting Markdown status:needs discussion Issues needing discussion and a decision to be made before action can be taken labels Sep 18, 2020
@bschlenk
Copy link
Contributor Author

bschlenk commented Dec 28, 2020

It may be easier for me to fix the markdown renderer my company uses, but I'd like to bring up a few points of discussion first:

  • the original PR mentions some public formatters (bitbucket) are also broken by this
  • markdown definitions are technically not prose
  • some people would like to enable proseWrap but not risk breaking markdown renderers
  • markdown definitions are typically going to be something short inside the [], followed by something long
    • line breaking after something short feels like a waste of horizontal space and doesn't necessarily make what follows prettier or more readable (see example below)
[link]:
  https://my-website.com/this-is-a-really-long-url-that-causes-the-line-to-wrap

In this example, the extra newline feels messy to me, and only moves the link left 6 characters. A url that causes wrapping will most likely still go beyond 80 characters.

I see the value of this setting when a title is used after the link url. Perhaps a compromise would be to retain the current wrapping behavior when a title is used, but never add a line break when a title is not present, regardless of the proseWrap setting? That would allow someone who is fighting a fussy markdown renderer to keep proseWrap: always by remembering to omit titles in definitions.

I sort of see this being similar to the decision to special case mocha test strings on a single line, even when otherwise the rules would have them break.

Regardless of whether markdown renderers support new lines in definitions, I find it more pleasing to the eye to have the definition all on one line, as it makes scanning the definitions list much easier.

@pbrisbin
Copy link

pbrisbin commented Oct 15, 2021

Hi there- are there any plans to address (or discuss) this issue?

I'm the author of Restyled, which offers prettier-markdown automation on PRs as one of its "restylers", and I'm probably going to move it to an opt-in status, since it can't be trusted not to break links like this. I'd love to avoid that if this issue had any traction.

@rmartine-ias
Copy link

Commenting to express support for this as well -- besides breaking some rendering, I really do not like how it looks.

@JavierJF
Copy link

Hi there,

I was going to make a PR for this, but after reading the CONTRIBUTING guidelines, I have seen that there is a no-new options policy very clearly stated. But, since this is flagged as needs discussion, I will leave here a link to a branch I have with a fix for this. I will submit a PR in case discussion evolves here and I'm asked to.

@paddyroddy
Copy link

Have encountered this too. Seems to work for GitHub-flavoured markdown, but was deploying a Jekyll GitHub Pages site and hadn't spotted it had broken that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang:markdown Issues affecting Markdown status:needs discussion Issues needing discussion and a decision to be made before action can be taken
Projects
None yet
Development

No branches or pull requests

6 participants