Explorar el Código

Further fix of exporting attachment links in export backends

* lisp/ox-html.el (org-html-link, org-html-inline-image-rules)
* lisp/ox-odt.el (org-odt-inline-image-rules)
* lisp/ox-texinfo.el (org-texinfo-link)
  (org-texinfo-inline-image-rules): Make attachment links consistently
  expand as relative to file and add attachment link type to
  image rules for consistency among export backends.
Gustav Wikström hace 5 años
padre
commit
0ac6a9e1fc
Se han modificado 3 ficheros con 7 adiciones y 6 borrados
  1. 2 4
      lisp/ox-html.el
  2. 2 1
      lisp/ox-odt.el
  3. 3 1
      lisp/ox-texinfo.el

+ 2 - 4
lisp/ox-html.el

@@ -886,6 +886,7 @@ link to the image."
 
 (defcustom org-html-inline-image-rules
   `(("file" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg")))
+    ("attachment" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg")))
     ("http" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg")))
     ("https" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg"))))
   "Rules characterizing image files that can be inlined into HTML.
@@ -3079,11 +3080,8 @@ INFO is a plist holding contextual information.  See
 	   ((member type '("http" "https" "ftp" "mailto" "news"))
 	    (url-encode-url (concat type ":" raw-path)))
 	   ((string= type "file")
-	    ;; Pre-parse the path from attachment-format to
-	    ;; file-format to make attachment links use all export
-	    ;; functionality from file links with correct pathing.
 	    (when (string= raw-type "attachment")
-	      (setq raw-path (org-attach-expand raw-path)))
+	      (setq raw-path (file-relative-name (org-attach-expand raw-path))))
 	    ;; During publishing, turn absolute file names belonging
 	    ;; to base directory into relative file names.  Otherwise,
 	    ;; append "file" protocol to absolute file name.

+ 2 - 1
lisp/ox-odt.el

@@ -745,7 +745,8 @@ link's path."
 		:value-type (regexp :tag "Path")))
 
 (defcustom org-odt-inline-image-rules
-  '(("file" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
+  '(("file" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg")))
+    ("attachment" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg"))))
   "Rules characterizing image files that can be inlined into ODT.
 
 A rule consists in an association whose key is the type of link

+ 3 - 1
lisp/ox-texinfo.el

@@ -407,6 +407,8 @@ If two strings share the same prefix (e.g. \"ISO-8859-1\" and
 
 (defconst org-texinfo-inline-image-rules
   (list (cons "file"
+	      (regexp-opt '("eps" "pdf" "png" "jpg" "jpeg" "gif" "svg")))
+	 (cons "attachment"
 	      (regexp-opt '("eps" "pdf" "png" "jpg" "jpeg" "gif" "svg"))))
   "Rules characterizing image files that can be inlined.")
 
@@ -1064,7 +1066,7 @@ INFO is a plist holding contextual information.  See
 		 (concat type ":" raw-path))
 		((string= type "file")
 		 (when (string= raw-type "attachment")
-		   (setq raw-path (org-attach-expand raw-path)))
+		   (setq raw-path (file-relative-name (org-attach-expand raw-path))))
 		 (org-export-file-uri raw-path))
 		(t raw-path))))
     (cond