Mu4e: use file when imagemagik not present
We will also use this as an opportunity to clean up the use of +org-msg-img-scale-css.
This commit is contained in:
parent
fe5e410b74
commit
7e1f7915c0
1 changed files with 25 additions and 21 deletions
|
@ -38,14 +38,19 @@ clicked."
|
||||||
(defun +org-msg-img-scale-css (img-uri)
|
(defun +org-msg-img-scale-css (img-uri)
|
||||||
"For a given IMG-URI, use imagemagik to find its width."
|
"For a given IMG-URI, use imagemagik to find its width."
|
||||||
(if +org-msg-currently-exporting
|
(if +org-msg-currently-exporting
|
||||||
;; TODO change to use 'file' (NB: would only work for PNG though, apparently)
|
(when (and (not IS-WINDOWS)) ; relies on posix path
|
||||||
(let ((width-call (doom-call-process "identify" "-format" "%w"
|
(let ((with-call (and (executable-find "identify")
|
||||||
(substring img-uri 7)))) ; 7=(length "file://")
|
(doom-call-process "identify" "-format" "%w"
|
||||||
(when (= (car width-call) 0)
|
(substring img-uri 7))))) ; 7=(length "file://")
|
||||||
(list :width
|
(unless width-call
|
||||||
(format "%.1fpx"
|
(setq width-call (doom-call-process "file" (substring img-uri 7)))
|
||||||
(/ (string-to-number (cdr width-call))
|
(setcdr width-call (replace-regexp-in-string "^.*image data, \\([0-9]+\\).*$" "\\1" (cdr width-call)))
|
||||||
(plist-get org-format-latex-options :scale))))))
|
(setcar width-call (if (< 0 (string-to-number (cdr width-call))) 0 1)))
|
||||||
|
(when (= (car width-call) 0)
|
||||||
|
(list :width
|
||||||
|
(format "%.1fpx"
|
||||||
|
(/ (string-to-number (cdr width-call))
|
||||||
|
(plist-get org-format-latex-options :scale)))))))
|
||||||
(list :style (format "transform: scale(%.3f)"
|
(list :style (format "transform: scale(%.3f)"
|
||||||
(/ 1.0 (plist-get org-format-latex-options :scale))))))
|
(/ 1.0 (plist-get org-format-latex-options :scale))))))
|
||||||
|
|
||||||
|
@ -70,14 +75,13 @@ account for the value of :scale in `org-format-latex-options'."
|
||||||
(org-html-format-latex latex-frag processing-type info)))
|
(org-html-format-latex latex-frag processing-type info)))
|
||||||
(when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
|
(when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
|
||||||
(let ((source (org-export-file-uri (match-string 1 formula-link)))
|
(let ((source (org-export-file-uri (match-string 1 formula-link)))
|
||||||
(attributes (list :alt latex-frag
|
(attributes (append (list :alt latex-frag
|
||||||
:class (concat "latex-fragment-"
|
:class
|
||||||
(if (equal "\\(" (substring latex-frag 0 2))
|
(concat "latex-fragment-"
|
||||||
"inline" "block")))))
|
(if (equal "\\(" (substring latex-frag 0 2))
|
||||||
(when (and (memq processing-type '(dvipng convert))
|
"inline" "block")))
|
||||||
(not IS-WINDOWS) ; relies on posix path
|
(when (memq processing-type '(dvipng convert))
|
||||||
(executable-find "identify"))
|
(+org-msg-img-scale-css source)))))
|
||||||
(apply #'plist-put attributes (+org-msg-img-scale-css source)))
|
|
||||||
(org-html--format-image source attributes info)))))
|
(org-html--format-image source attributes info)))))
|
||||||
(t latex-frag))))
|
(t latex-frag))))
|
||||||
|
|
||||||
|
@ -118,11 +122,11 @@ scales the image to account for the value of :scale in `org-format-latex-options
|
||||||
processing-type info)))
|
processing-type info)))
|
||||||
(when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
|
(when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
|
||||||
(let ((source (org-export-file-uri (match-string 1 formula-link))))
|
(let ((source (org-export-file-uri (match-string 1 formula-link))))
|
||||||
(when (and (memq processing-type '(dvipng convert))
|
|
||||||
(not IS-WINDOWS) ; relies on posix path
|
|
||||||
(executable-find "identify"))
|
|
||||||
(apply #'plist-put attributes (+org-msg-img-scale-css source)))
|
|
||||||
(org-html--wrap-latex-environment
|
(org-html--wrap-latex-environment
|
||||||
(org-html--format-image source attributes info)
|
(org-html--format-image source
|
||||||
|
(append attributes
|
||||||
|
(when (memq processing-type '(dvipng convert))
|
||||||
|
(+org-msg-img-scale-css source)))
|
||||||
|
info)
|
||||||
info caption label)))))
|
info caption label)))))
|
||||||
(t (org-html--wrap-latex-environment latex-frag info caption label)))))
|
(t (org-html--wrap-latex-environment latex-frag info caption label)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue