branch: elpa/markdown-mode
commit c12adcfbeb2d45d376df50c843758c6ef22fdd08
Merge: 50e4452c95 0a6a8d8593
Author: Shohei YOSHIDA <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #801 from jrblevin/issue-800
Support links with angle brackets
---
markdown-mode.el | 16 +++++++++-------
tests/markdown-test.el | 8 ++++++++
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/markdown-mode.el b/markdown-mode.el
index cd066a899d..0cf1b54556 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -168,7 +168,7 @@ defined by Markdown and HTML. Increasing this produces
extra
whitespace on the left. Decreasing it may be preferred when
fewer than six nested heading levels are used."
:group 'markdown
- :type 'natnump
+ :type 'integer
:safe 'natnump
:package-version '(markdown-mode . "2.4"))
@@ -301,7 +301,6 @@ be used."
This may be a single string or a list of string. In case of a
list, the first one that satisfies `char-displayable-p' will be
used."
- :type 'string
:type '(choice
(string :tag "Single blockquote display string")
(repeat :tag "List of possible blockquote display strings" string))
@@ -2066,7 +2065,7 @@ headers of levels one through six respectively."
'(2.0 1.7 1.4 1.1 1.0 1.0)
"List of scaling values for headers of level one through six.
Used when `markdown-header-scaling' is non-nil."
- :type 'list
+ :type '(repeat float)
:initialize #'custom-initialize-default
:set (lambda (symbol value)
(set-default symbol value)
@@ -7856,10 +7855,13 @@ Value is a list of elements describing the link:
(let* ((close-pos (scan-sexps (match-beginning 5) 1))
(destination-part (string-trim (buffer-substring-no-properties
(1+ (match-beginning 5)) (1- close-pos)))))
(setq end close-pos)
- (if (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))
- (setq url destination-part))))
+ ;; A link can contain spaces if it is wrapped with angle brackets
+ (cond ((string-match "\\`<\\(.+\\)>\\'" destination-part)
+ (setq url (match-string-no-properties 1 destination-part)))
+ ((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)))))
;; 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 10b89ae2ed..c8213d82f7 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -5366,6 +5366,14 @@ Detail:
https://github.com/jrblevin/markdown-mode/issues/430"
(markdown-test-string ""
(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 .
+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/reference-link-at-pos ()
"Test `markdown-link-at-pos' return values with a reference link."
(markdown-test-string "[text][ref]"