diff --git a/CHANGES.md b/CHANGES.md index a758f211..0604a9a3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,7 +5,11 @@ * Bug fixes: - Don't highlight superscript/subscript in math inline/block [GH-802][] +* Improvements: + - Apply url-unescape against URL in an inline link [GH-805][] + [gh-802]: https://github.com/jrblevin/markdown-mode/issues/802 + [gh-805]: https://github.com/jrblevin/markdown-mode/issues/805 # Markdown Mode 2.6 diff --git a/markdown-mode.el b/markdown-mode.el index f549870b..3abecce9 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -7866,7 +7866,8 @@ Value is a list of elements describing the link: ((string-match "\\([^ ]+\\)\\s-+\\(.+\\)" destination-part) (setq url (match-string-no-properties 1 destination-part) title (substring (match-string-no-properties 2 destination-part) 1 -1))) - (t (setq url destination-part))))) + (t (setq url destination-part))) + (setq url (url-unhex-string url)))) ;; Reference link at point. ((thing-at-point-looking-at markdown-regex-link-reference) (setq bang (match-string-no-properties 1) diff --git a/tests/markdown-test.el b/tests/markdown-test.el index 29f18c33..22b7c9ea 100644 --- a/tests/markdown-test.el +++ b/tests/markdown-test.el @@ -5367,13 +5367,23 @@ Detail: https://github.com/jrblevin/markdown-mode/issues/430" (should (equal (markdown-link-at-pos (point)) '(1 21 "text" "url" nil "title" "!"))))) (ert-deftest test-markdown-link/inline-link-with-brackets () - "Test `markdown-link-at-pos' return values with . + "Test `markdown-link-at-pos' return values with a link with backets. Details: https://github.com/jrblevin/markdown-mode/issues/800 A link can contain spaces if it is wrapped with angle brackets" (markdown-test-string "[text]()" (should (equal (markdown-link-at-pos (point)) '(1 30 "text" "file name has space" nil nil nil))))) +(ert-deftest test-markdown-link/inline-link-with-url-escape () + "Test `markdown-link-at-pos' return values with a link with url escapes. +Details: https://github.com/jrblevin/markdown-mode/issues/805 + +A link can contain spaces if it is wrapped with angle brackets" + (markdown-test-string "[text](bar%20baz.md)" + (should (equal (nth 3 (markdown-link-at-pos (point))) "bar baz.md"))) + (markdown-test-string "[text]()" + (should (equal (nth 3 (markdown-link-at-pos (point))) "bar baz.md")))) + (ert-deftest test-markdown-link/reference-link-at-pos () "Test `markdown-link-at-pos' return values with a reference link." (markdown-test-string "[text][ref]"