diff --git a/lisp/org-element.el b/lisp/org-element.el index 703b35571..be7d6c83f 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -3002,11 +3002,16 @@ Assume point is at the beginning of the link." (setq contents-begin (match-beginning 3) contents-end (match-end 3) link-end (match-end 0) - ;; RAW-LINK is the original link. + ;; RAW-LINK is the original link. Expand any + ;; abbreviation in it. raw-link (org-translate-link (org-link-expand-abbrev (org-match-string-no-properties 1))) - link (org-link-unescape raw-link)) + ;; Remove newline characters due to filling. Headlines, + ;; targets, radio targets and name affiliated keywords + ;; cannot contain any. + link (org-link-unescape + (replace-regexp-in-string "\n" " " raw-link))) ;; Determine TYPE of link and set PATH accordingly. (cond ;; File type. diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 902198ab8..0f2f93f51 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -1288,7 +1288,13 @@ e^{i\\pi}+1=0 (org-element-map (org-element-parse-buffer) 'link (lambda (link) (org-element-property :type link)) - nil t nil t)))))) + nil t nil t))))) + ;; Corner case: links with filled path. + (should + (equal "a b" + (org-test-with-temp-text "* a b\n[[a\nb]]" + (progn (forward-line 1) + (org-element-property :path (org-element-context))))))) ;;;; Macro