branch: elpa/markdown-mode
commit d004ddc6084073886ed09ed274ca955f06db1d39
Author: Shohei YOSHIDA <syo...@gmail.com>
Commit: Shohei YOSHIDA <syo...@gmail.com>

    Apply URL unescape againt URL in a inline link
---
 CHANGES.md             |  4 ++++
 markdown-mode.el       |  3 ++-
 tests/markdown-test.el | 12 +++++++++++-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index a758f2114e..0604a9a398 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 f549870bb8..3abecce927 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 29f18c33c0..22b7c9ea9e 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](<file name has space>)"
     (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](<bar%20baz.md>)"
+    (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]"

Reply via email to