Преглед на файлове

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.
Nicolas Goaziou преди 9 години
родител
ревизия
716e339c96
променени са 3 файла, в които са добавени 22 реда и са изтрити 8 реда
  1. 6 0
      etc/ORG-NEWS
  2. 8 6
      lisp/org-element.el
  3. 8 2
      testing/lisp/test-org-element.el

+ 6 - 0
etc/ORG-NEWS

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

+ 8 - 6
lisp/org-element.el

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

+ 8 - 2
testing/lisp/test-org-element.el

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