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.
This commit is contained in:
Nicolas Goaziou 2013-02-11 23:16:25 +01:00
parent e5322d77f2
commit 9f8f32c360
2 changed files with 14 additions and 3 deletions

View File

@ -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.

View File

@ -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