From: Carlo Nucera <meditans@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH]: Fix latex image bug in org-mime-org-buffer-htmlize
Date: Sat, 11 Jun 2016 01:32:47 +0200 [thread overview]
Message-ID: <CALaN21OuTZ_JMwXP66-H7Uzm=MTHg5cLCAArLJaHv--E_XXuzg@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 882 bytes --]
Hi,
attached is a patch that should fix a bug in the function
org-mime-org-buffer-htmlize (thanks to punchagan on irc!).
When exporting an org buffer with a latex snippet including the org
option tex: dvipng the images were always created in /tmp/ltxpng/, but
the reported link in the htmlized buffer was the local ./ltxpng folder;
so, unless the org file to htmlize was actually in /tmp, the user got an
error saying that the image could not be found.
This was caused by the two different ways in which the function
org-mime-replace-images is used inside of org-mime-org-buffer-htmlize
and org-mime-htmlize.
To correct the problem, the function org-mime-replace-images doesn't
take anymore the current-file parameter (that was only used to get its
directory) and instead always creates a temporary directory using
temporary-file-directory.
Keep up the good work!
Carlo Nucera
[-- Attachment #2: 0001-Fix-latex-image-bug-in-org-mime-org-buffer-htmlize.patch --]
[-- Type: text/x-patch, Size: 3311 bytes --]
From e8dcf9996481053da856cd6684898cff28df0213 Mon Sep 17 00:00:00 2001
From: meditans <meditans@gmail.com>
Date: Fri, 10 Jun 2016 23:32:05 +0200
Subject: [PATCH] Fix latex image bug in org-mime-org-buffer-htmlize
When exporting an org buffer with a latex snippet including the org
option tex: dvipng the images were always created in /tmp/ltxpng/, but
the reported link in the htmlized buffer was the local ./ltxpng folder;
so, unless the org file to htmlize was actually in /tmp, the user got an
error saying that the image could not be found.
This was caused by the two different ways in which the function
org-mime-replace-images is used inside of org-mime-org-buffer-htmlize
and org-mime-htmlize.
To correct the problem, the function org-mime-replace-images doesn't
take anymore the current-file parameter (that was only used to get its
directory) and instead always creates a temporary directory using
temporary-file-directory.
---
contrib/lisp/org-mime.el | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/contrib/lisp/org-mime.el b/contrib/lisp/org-mime.el
index 682f635..42fee3c 100644
--- a/contrib/lisp/org-mime.el
+++ b/contrib/lisp/org-mime.el
@@ -173,7 +173,7 @@ and images in a multipart/related part."
"--" "}-<<alternative>>\n"))
('vm "?")))
-(defun org-mime-replace-images (str current-file)
+(defun org-mime-replace-images (str)
"Replace images in html files with cid links."
(let (html-images)
(cons
@@ -185,7 +185,7 @@ and images in a multipart/related part."
(let* ((url (and (string-match "src=\"\\([^\"]+\\)\"" text)
(match-string 1 text)))
(path (expand-file-name
- url (file-name-directory current-file)))
+ url temporary-file-directory))
(ext (file-name-extension path))
(id (replace-regexp-in-string "[\/\\\\]" "_" path)))
(add-to-list 'html-images
@@ -212,8 +212,6 @@ otherwise export the entire body."
(point-max)))
(raw-body (concat org-mime-default-header
(buffer-substring html-start html-end)))
- (tmp-file (make-temp-name (expand-file-name
- "mail" temporary-file-directory)))
(body (org-export-string-as raw-body 'org t))
;; because we probably don't want to export a huge style file
(org-export-htmlize-output-type 'inline-css)
@@ -224,7 +222,7 @@ otherwise export the entire body."
;; to hold attachments for inline html images
(html-and-images
(org-mime-replace-images
- (org-export-string-as raw-body 'html t) tmp-file))
+ (org-export-string-as raw-body 'html t)))
(html-images (unless arg (cdr html-and-images)))
(html (org-mime-apply-html-hook
(if arg
@@ -317,7 +315,7 @@ otherwise export the entire body."
(org-export-htmlize-output-type 'inline-css)
(html-and-images
(org-mime-replace-images
- (org-export-string-as (funcall bhook body 'html) 'html t) file))
+ (org-export-string-as (funcall bhook body 'html) 'html t)))
(images (cdr html-and-images))
(html (org-mime-apply-html-hook (car html-and-images))))
(insert (org-mime-multipart
--
2.5.5
next reply other threads:[~2016-06-10 23:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-10 23:32 Carlo Nucera [this message]
2016-06-14 12:25 ` [PATCH]: Fix latex image bug in org-mime-org-buffer-htmlize Nicolas Goaziou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALaN21OuTZ_JMwXP66-H7Uzm=MTHg5cLCAArLJaHv--E_XXuzg@mail.gmail.com' \
--to=meditans@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).