-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Break link definitions onto multiple lines when needed #3531
Conversation
src/printer-markdown.js
Outdated
printUrl(node.url), | ||
node.title ? line : null, | ||
node.title ? printTitle(node.title) : null | ||
].filter(x => x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be better this way as it's more intuitive:
concat([
line,
printUrl(node.url),
node.title === null
? ""
: concat([line, printTitle(node.title)])
])
And also we should add a test case for empty title:
[something]: http://prettier.io ""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the ""
can be removed when the title is blank. Markdown (at least CommonMark) doesn’t render links with empty titles differently from links without titles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll change the AST (at least remark
's), we shouldn't touch it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...sorry, I thought node.title
was ""
in that case, it seems they're all parsed as null
. But results are the same anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--> #3531 (comment)
src/printer-markdown.js
Outdated
concat([ | ||
line, | ||
printUrl(node.url), | ||
node.title === null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry that this will break some renderers (specifically BitBucket Server). Maybe we could make it respect |
from BitBucket Support - Markdown syntax guide:
It seems they should render it correctly, but they actually didn't follow the CommonMark Spec. I'm not sure what should we do here since the link definition does not look like a prose. |
9f192cb
to
f89a823
Compare
Rebased to fix the merge conflicts. |
👍/👎? |
Should we merge this or should I 🗑 it? |
@lipis GitHub renders them correctly: just-url url-with-short-title url-with-long-title long long-with-title |
the result is correct.. but when they are fenced? Either case I would prefer to not break them or at least respect the |
Respecting |
What's the status with this one? |
I’m not sure — should this get merged as-is or should it be modified to respect |
I would respect the |
So shall we add the 1.13 tag for a friendly pressure? |
Sure 😀 |
Allows to select if Markdown definitions should be broken when 'proseWrap' is set to 'always'. Single line reference links helps preventing potential rendering issues.
Allows to select if Markdown definitions should be broken when 'proseWrap' is set to 'always'. This enables, for example, single line reference links, which can prevent potential rendering issues.
Ref #3481.
Prettier 1.9.2
Playground link
Input:
Output:
Output after this PR:
Preview playground link