-
-
Notifications
You must be signed in to change notification settings - Fork 70
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 links with spaces #112
Comments
To anyone still interested in this, what markdown platform/flavor are you using where a newline in the link text breaks the link? I thought about making it so that [all spaces within a link] would be made non-breaking, but then the end result isn't really pleasing either, since you then have one very long line with link text and the URL. How I now work around this is by putting a space either before the closing "]" for the text or after the opening "(" for the URL. This gives the best result for me. |
I just use VS Code's built-in markdown editor, along with extensions mjbvz/vscode-github-markdown-preview-style and yzane/vscode-markdown-pdf. Looking at it now, the resulting link does still work in both outputs, as well as the built-in VS Code markdown preview. I don't remember anymore whether that was the case when I filed the issue. However, wrapping in the middle of the link text does break VS Code's syntax highlighting for the link.
Yeah, I could see someone preferring it either way. I typically have fairly short link text even when there are spaces involved, so if the URL is long enough that it forces the line to wrap then the line with the URL is going to be pretty long regardless, and the link text doesn't make much difference. It might be nice to have a setting for whether to treat spaces in link text as breaking or non-breaking. I would still be willing to attempt a PR if you agree with this. |
@rdnlsmith Thanks for the offer but the code is in a really messy and volatile state right now while I'm rewriting lots of stuff. I do plan to add a feature, where users can add find/replace operations that are performed at the same time as wrapping, and that will let anyone experiment with converting spaces in links to non-breaking (which I'm still not sure is a good idea). |
I don't know which tool you are using, but the widely accepted CommonMark specs allow the line breaks inside the linkt tile:
So, IMO, this is not a bug. |
First off, this is a fantastic extension. I write a lot of Markdown, and the auto-wrap feature makes it a really nice experience!
The one problem I have is with links that have spaces in the link text. If a link is at the end of a line (or has a very long URL) and there are no spaces, it correctly moves the link to the next line:
becomes
But, if there is a space in the link text, it wraps at the space, breaking the link:
becomes
I often get around this by placing links on their own line within the paragraph, but if the URL is long enough to go past the wrap boundary, it will be auto-wrapped as soon as I press enter.
It would be great if Rewrap could support this! I'd be glad to attempt a PR if you'd like.
The text was updated successfully, but these errors were encountered: