Allow angular links within link descriptions

* lisp/org-element.el (org-element-object-restrictions):
(org-element--object-lex): Allow angular links as equivalent to plain
links in description.

* testing/lisp/test-org-element.el (test-org-element/link-parser): Add
  test.
This commit is contained in:
Nicolas Goaziou 2016-04-06 11:08:53 +02:00
parent 64ca6f2c24
commit 716e339c96
3 changed files with 22 additions and 8 deletions

View File

@ -286,6 +286,12 @@ plain list.
*** ~fixltx2e~ is removed from ~org-latex-default-packages-alist~
fixltx2e is obsolete, see LaTeX News 22.
** Miscellaneous
*** Allow angular links within link descriptions
It is now allowed to write, e.g.,
~[[http:orgmode.org][<file:unicorn.png>]]~ as an equivalent to
~[[http:orgmode.org][file:unicorn.png]]~. The advantage of the former
is that spaces are allowed within the path.
*** Beamer export back-ends uses ~org-latex-prefer-user-labels~
*** ~:preparation-function~ called earlier during publishing

View File

@ -352,10 +352,11 @@ Don't modify it, set `org-element-affiliated-keywords' instead.")
(italic ,@standard-set)
(item ,@standard-set-no-line-break)
(keyword ,@(remq 'footnote-reference standard-set))
;; Ignore all links excepted plain links in a link description.
;; Also ignore radio-targets and line breaks.
;; Ignore all links excepted plain links and angular links in
;; a link description. Also ignore radio-targets and line
;; breaks.
(link bold code entity export-snippet inline-babel-call inline-src-block
italic latex-fragment macro plain-link statistics-cookie
italic latex-fragment macro simple-link statistics-cookie
strike-through subscript superscript underline verbatim)
(paragraph ,@standard-set)
;; Remove any variable object from radio target as it would
@ -4336,7 +4337,8 @@ to an appropriate container (e.g., a paragraph)."
(org-element-target-parser)))
(or (and (memq 'timestamp restriction)
(org-element-timestamp-parser))
(and (memq 'link restriction)
(and (or (memq 'link restriction)
(memq 'simple-link restriction))
(org-element-link-parser)))))
(?\\
(if (eq (aref result 1) ?\\)
@ -4358,8 +4360,8 @@ to an appropriate container (e.g., a paragraph)."
(org-element-statistics-cookie-parser)))))
;; This is probably a plain link.
(_ (and (or (memq 'link restriction)
(memq 'plain-link restriction))
(org-element-link-parser)))))))
(memq 'simple-link restriction))
(org-element-link-parser)))))))
(or (eobp) (forward-char))))
(cond (found)
;; Radio link.

View File

@ -1688,8 +1688,8 @@ e^{i\\pi}+1=0
(org-element-type (org-element-context)))))
(should
(equal "//orgmode.org"
(org-test-with-temp-text "A link: <point><http://orgmode\n.org>"
(org-element-property :path (org-element-context)))))
(org-test-with-temp-text "A link: <point><http://orgmode\n.org>"
(org-element-property :path (org-element-context)))))
;; Link abbreviation.
(should
(equal "http"
@ -1711,6 +1711,12 @@ e^{i\\pi}+1=0
(should
(equal "file"
(org-test-with-temp-text "[[http://orgmode.org][file:unicorn.jpg]]"
(search-forward "file:")
(org-element-property :type (org-element-context)))))
;; So are angular links.
(should
(equal "file"
(org-test-with-temp-text "[[http://orgmode.org][<file:unicorn.jpg>]]"
(search-forward "file:")
(org-element-property :type (org-element-context))))))