Explorar o código

Merge branch 'maint'

Nicolas Goaziou %!s(int64=8) %!d(string=hai) anos
pai
achega
473ca5c86c
Modificáronse 3 ficheiros con 8 adicións e 6 borrados
  1. 1 1
      lisp/org-element.el
  2. 5 3
      lisp/ox.el
  3. 2 2
      testing/lisp/test-ox.el

+ 1 - 1
lisp/org-element.el

@@ -3195,7 +3195,7 @@ Assume point is at the beginning of the link."
 	(when (string-match "::\\(.*\\)\\'" path)
 	  (setq search-option (match-string 1 path))
 	  (setq path (replace-match "" nil nil path)))
-	(setq path (replace-regexp-in-string "\\`///+" "/" path)))
+	(setq path (replace-regexp-in-string "\\`///*\\(.:\\)?/" "\\1/" path)))
       ;; Translate link, if `org-link-translation-function' is set.
       (let ((trans (and (functionp org-link-translation-function)
 			(funcall org-link-translation-function type path))))

+ 5 - 3
lisp/ox.el

@@ -4390,11 +4390,13 @@ has type \"radio\"."
 
 (defun org-export-file-uri (filename)
   "Return file URI associated to FILENAME."
-  (cond ((string-match-p "\\`//" filename) (concat "file:" filename))
+  (cond ((string-prefix-p "//" filename) (concat "file:" filename))
 	((not (file-name-absolute-p filename)) filename)
 	((org-file-remote-p filename) (concat "file:/" filename))
-	(t (concat "file://" (expand-file-name filename)))))
-
+	(t
+	 (let ((fullname (expand-file-name filename)))
+	   (concat (if (string-prefix-p "/" fullname) "file://" "file:///")
+		   fullname)))))
 
 ;;;; For References
 ;;

+ 2 - 2
testing/lisp/test-ox.el

@@ -3311,7 +3311,7 @@ Another text. (ref:text)
   ;; Preserve relative filenames.
   (should (equal "relative.org" (org-export-file-uri "relative.org")))
   ;; Local files start with "file://"
-  (should (equal (concat "file://" (expand-file-name "/local.org"))
+  (should (equal (concat (if (memq system-type '(windows-nt cygwin)) "file:///" "file://") (expand-file-name "/local.org"))
 		 (org-export-file-uri "/local.org")))
   ;; Remote files start with "file://"
   (should (equal "file://myself@some.where:papers/last.pdf"
@@ -3320,7 +3320,7 @@ Another text. (ref:text)
 		 (org-export-file-uri "//localhost/etc/fstab")))
   ;; Expand filename starting with "~".
   (should (equal (org-export-file-uri "~/file.org")
-		 (concat "file://" (expand-file-name "~/file.org")))))
+		 (concat (if (memq system-type '(windows-nt cygwin)) "file:///" "file://") (expand-file-name "~/file.org")))))
 
 (ert-deftest test-org-export/get-reference ()
   "Test `org-export-get-reference' specifications."