From 9f8f32c3603bbb2c6f788cb177c5fb193d86dd57 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 11 Feb 2013 23:16:25 +0100 Subject: [PATCH] org-element: Fix parsing of links with filled path * lisp/org-element.el (org-element-link-parser): Remove all newline characters in path property. * testing/lisp/test-org-element.el: Add test. --- lisp/org-element.el | 9 +++++++-- testing/lisp/test-org-element.el | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) 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