-
Notifications
You must be signed in to change notification settings - Fork 163
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
Weird filling behavior for paragraphs containing links #173
Comments
This seems to have been fixed already. I added your example as a test case to prevent future regressions. Thanks for the report. |
Thanks, but I think this isn't fixed yet if the fill column is set to 79 (this does seem to be necessary after all). |
Another case is e.g. aaa [aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa](a) aaa. with a fill column of 40. Filling that paragraph should introduce line breaks inside the link text, but doesn't. |
Thanks. I missed the point about setting the Indeed, (add-hook 'fill-nobreak-predicate
'markdown-inside-link-p nil t) I think there is a good reason why, but I'll have to check to refresh my memory. |
Looks like this originated in 0c239e2, presumably as an aesthetic preference. I'll work on making this behavior customizable, but as a temporary workaround you can write a function that runs with
|
Thanks for finding the original commit. I remember that now (nearly 8 years ago!) It seems the latest Maruku correctly parses links with line breaks in the text (see here), so I will revert the non-breaking behavior. |
I've been using the workaround in #173 (comment) for a couple of days now and haven't encountered any issues. |
Thanks again for the report. |
Thanks for the fix! |
@jrblevin sorry to necro this, but I wanted to put my solution to stopping line wrapping Markdown links here. Given the following Markdown: This is a [very long link](https://www.example.com/very/very/very/very/long).
This is a [ridiculously long link](https://www.example.com/very/very/very/very/very/very/very/long) with stuff coming after.
- This is a [ridiculously long link in a list](https://www.example.com/very/very/very/very/very/very/very/long) with stuff coming after. And the following code in my .emacs: (defun mxe:markdown-mode-install-fill-nobreak-predicates ()
"These hooks are mode-specific and must be buffer-local as a
result."
(add-hook 'fill-nobreak-predicate
'markdown-inside-link-p nil t))
(with-eval-after-load 'markdown-mode
(add-hook 'markdown-mode-hook #'mxe:markdown-mode-install-fill-nobreak-predicates)) The This is
a [very long link](https://www.example.com/very/very/very/very/long).
This is
a
[ridiculously long link](https://www.example.com/very/very/very/very/very/very/very/long) with
stuff coming after.
- This is
a
[ridiculously long link in a list](https://www.example.com/very/very/very/very/very/very/very/long) with
stuff coming after. I'd prefer space within links be treated as non-breakable while allowing breaks before and after: (defun mxe:markdown-link-fill-nobreak ()
"Do not break lines in the middle of Markdown links when filling
paragraphs. This function is designed for use in
`fill-nobreak-predicate'.
[A Markdown link](https://www.example.com/)
^ ^
|--- breaks allowed before, after here ---|"
;; TODO: memoize this somehow
(let ((pos (point)))
(cl-destructuring-bind (start end text link ref title bang)
(markdown-link-at-pos pos)
(and
(or start end text link ref title bang)
(< start pos end)))))
(defun mxe:markdown-mode-install-fill-nobreak-predicates ()
"These hooks are mode-specific and must be buffer-local as a
result."
(add-hook 'fill-nobreak-predicate
#'mxe:markdown-link-fill-nobreak nil t))
(with-eval-after-load 'markdown-mode
(add-hook 'markdown-mode-hook #'mxe:markdown-mode-install-fill-nobreak-predicates)) Now long links get placed on their own line. Filled paragraphs look neater as a result. This is a
[very long link](https://www.example.com/very/very/very/very/long).
This is a
[ridiculously long link](https://www.example.com/very/very/very/very/very/very/very/long)
with stuff coming after.
- This is a
[ridiculously long link in a list](https://www.example.com/very/very/very/very/very/very/very/long)
with stuff coming after. |
This is for version 20160928.932.
To reproduce, create a new buffer in markdown-mode, disable auto-fill-mode, and set fill-column to 79. (The latter two aren't necessary, they just make the reproduction more obvious.) Then, insert the following as a single line:
The "words" themselves don't matter, it's only important that there is a lengthy paragraph with a link with a long URL. Then hit M-q to fill the paragraph. The result is
Note that there's a single "aaa" in front of the link, even though it would have fit on the previous line.
The text was updated successfully, but these errors were encountered: