diff options
author | Bastien Guerry <bzg@altern.org> | 2014-07-27 10:53:24 +0200 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2014-07-27 10:53:24 +0200 |
commit | 16e21ae1f7cb379eab87cc7c8c674d89633ae9a3 (patch) | |
tree | 71be16f45366e59910adead0d884628d11daff6a | |
parent | 092213b507cd5619c839df372ae93fbe3c7b57ab (diff) | |
parent | 30db07e427a43ce325e50b60c0a57f861475c16d (diff) | |
download | org-mode-16e21ae1f7cb379eab87cc7c8c674d89633ae9a3.tar.gz |
Merge branch 'master' of orgmode.org:org-mode
-rw-r--r-- | lisp/org-element.el | 14 | ||||
-rw-r--r-- | testing/lisp/test-org-element.el | 23 |
2 files changed, 23 insertions, 14 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el index 9621e15..31f042c 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -3012,16 +3012,20 @@ Assume point is at the beginning of the link." (cond ;; File type. ((or (file-name-absolute-p raw-link) - (string-match "^\\.\\.?/" raw-link)) + (string-match "\\`\\.\\.?/" raw-link)) (setq type "file" path raw-link)) ;; Explicit type (http, irc, bbdb...). See `org-link-types'. - ((string-match org-link-re-with-space3 raw-link) - (setq type (match-string 1 raw-link) path (match-string 2 raw-link))) + ((string-match org-link-types-re raw-link) + (setq type (match-string 1 raw-link) + ;; According to RFC 3986, extra whitespace should be + ;; ignored when a URI is extracted. + path (replace-regexp-in-string + "[ \t]*\n[ \t]*" "" (substring raw-link (match-end 0))))) ;; Id type: PATH is the id. - ((string-match "^id:\\([-a-f0-9]+\\)" raw-link) + ((string-match "\\`id:\\([-a-f0-9]+\\)" raw-link) (setq type "id" path (match-string 1 raw-link))) ;; Code-ref type: PATH is the name of the reference. - ((string-match "^(\\(.*\\))$" raw-link) + ((string-match "\\`(\\(.*\\))\\'" raw-link) (setq type "coderef" path (match-string 1 raw-link))) ;; Custom-id type: PATH is the name of the custom id. ((= (aref raw-link 0) ?#) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index d21f9da..8dc8723 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -1472,19 +1472,19 @@ e^{i\\pi}+1=0 (org-test-with-temp-text "[[file:projects.org::*task title]]" (org-element-map (org-element-parse-buffer) 'link (lambda (l) (list (org-element-property :type l) - (org-element-property :path l) - (org-element-property :search-option l))))))) - ;; ... file-type link with application. + (org-element-property :path l) + (org-element-property :search-option l))))))) + ;; ... file-type link with application... (should (equal - '(("file" "projects.org" "docview")) + '("file" "projects.org" "docview") (org-test-with-temp-text "[[docview:projects.org]]" - (org-element-map (org-element-parse-buffer) 'link - (lambda (l) (list (org-element-property :type l) - (org-element-property :path l) - (org-element-property :application l))))))) + (let ((l (org-element-context))) + (list (org-element-property :type l) + (org-element-property :path l) + (org-element-property :application l)))))) ;; ... `:path' in a file-type link must be compatible with "file" - ;; scheme in URI syntax, even if Org syntax isn't. + ;; scheme in URI syntax, even if Org syntax isn't... (should (org-test-with-temp-text-in-file "" (let ((file (expand-file-name (buffer-file-name)))) @@ -1502,6 +1502,11 @@ e^{i\\pi}+1=0 (let ((file (file-relative-name (buffer-file-name)))) (insert (format "[[file:%s]]" file)) (list (org-element-property :path (org-element-context)) file)))) + ;; ... multi-line link. + (should + (equal "//orgmode.org" + (org-test-with-temp-text "[[http://orgmode.\norg]]" + (org-element-property :path (org-element-context))))) ;; Plain link. (should (org-test-with-temp-text "A link: http://orgmode.org" |