From 0d94ccdf3e9537dcab0907b9ae0345cd97abd0ef Mon Sep 17 00:00:00 2001 From: TEC Date: Sun, 19 Jun 2022 00:13:49 +0800 Subject: [PATCH] Org LaTeX image export from URLs was upstreamed --- config.org | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/config.org b/config.org index 909cc81..887ad63 100644 --- a/config.org +++ b/config.org @@ -9682,46 +9682,6 @@ I'd quite like to also recognise =->= and =<-=, so let's set come up with some a output)) #+end_src -**** Support images from URLs -You can link to remote images easily, and they work nicely with HTML-based -exports. However, LaTeX can only include local files, and so the current -behaviour of =org-latex-link= is just to insert a URL to the image. - -We can do better than that by downloading the image to a predictable location, -and using that. By making the filename predictable as opposed to just another -tempfile, this can provide a caching mechanism. - -#+begin_src emacs-lisp -(defadvice! +org-latex-link (orig-fn link desc info) - "Acts as `org-latex-link', but supports remote images." - :around #'org-latex-link - (setq o-link link - o-desc desc - o-info info) - (if (and (member (plist-get (cadr link) :type) '("http" "https")) - (member (file-name-extension (plist-get (cadr link) :path)) - '("png" "jpg" "jpeg" "pdf" "svg"))) - (org-latex-link--remote link desc info) - (funcall orig-fn link desc info))) - -(defun org-latex-link--remote (link _desc info) - (let* ((url (plist-get (cadr link) :raw-link)) - (ext (file-name-extension url)) - (target (format "%s%s.%s" - (temporary-file-directory) - (replace-regexp-in-string "[./]" "-" - (file-name-sans-extension (substring (plist-get (cadr link) :path) 2))) - ext))) - (unless (file-exists-p target) - (url-copy-file url target)) - (setcdr link (--> (cadr link) - (plist-put it :type "file") - (plist-put it :path target) - (plist-put it :raw-link (concat "file:" target)) - (list it))) - (concat "% fetched from " url "\n" - (org-latex--inline-image link info)))) -#+end_src **** Chameleon --- aka. match theme Once I had the idea of having the look of the LaTeX document produced match the