Skip to content

Commit

Permalink
Merge pull request #806 from jrblevin/issue-805
Browse files Browse the repository at this point in the history
Apply URL unescape againt URL in a inline link
  • Loading branch information
syohex authored Oct 21, 2023
2 parents 31d4fef + d004ddc commit 2a0556c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 11 additions & 1 deletion tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand Down

0 comments on commit 2a0556c

Please sign in to comment.