emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Problem with org-html-format-latex
@ 2013-02-07 15:44 Vincent Beffara
  2013-02-07 16:26 ` Vincent Beffara
  0 siblings, 1 reply; 9+ messages in thread
From: Vincent Beffara @ 2013-02-07 15:44 UTC (permalink / raw)
  To: Org Mode List

Hi, 

Trying out the new exporter and hoping to have it work with o-blog ...

A bug occurs with org-html-format-latex (in ox-html.el) when called from a non-file buffer. In the context of o-blog, it gets called as (org-html-format-latex "$x$" 'mathjax) but still tries to bind some ltxpng related support. This ends up calling file-name-sans-extension to the output of (file-name-nondirectory (buffer-file-name)) which is nil ...

Crashing in such a case makes sense for ltxpng but not for mathjax.

This makes it work:

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index f4fc27b..03e09aa 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -1994,8 +1994,8 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(defun org-html-format-latex (latex-frag processing-type)
(let* ((cache-relpath
(concat "ltxpng/" (file-name-sans-extension
- (file-name-nondirectory (buffer-file-name)))))
- (cache-dir (file-name-directory (buffer-file-name )))
+ (file-name-nondirectory (or (buffer-file-name) "")))))
+ (cache-dir (file-name-directory (or (buffer-file-name) "")))
(display-msg "Creating LaTeX Image..."))

(with-temp-buffer



but feels like the wrong solution, probably cache-relpath and cache-dir should be set to nil in such a case ...

Regards,

/v 

-- 
Vincent Beffara

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: Problem with org-html-format-latex
  2013-02-07 15:44 Problem with org-html-format-latex Vincent Beffara
@ 2013-02-07 16:26 ` Vincent Beffara
  2013-02-08 18:49   ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Vincent Beffara @ 2013-02-07 16:26 UTC (permalink / raw)
  To: Org Mode List

[-- Attachment #1: Type: text/plain, Size: 421 bytes --]

Hi again, 
> A bug occurs with org-html-format-latex (in ox-html.el) when called from a non-file buffer. In the context of o-blog, it gets called as (org-html-format-latex "$x$" 'mathjax) but still tries to bind some ltxpng related support. This ends up calling file-name-sans-extension to the output of (file-name-nondirectory (buffer-file-name)) which is nil ...

Cleaner patch uses ignore-errors, that's simpler...

/v

[-- Attachment #2: 0001-Fix-the-non-file-buffer-bug.patch --]
[-- Type: application/octet-stream, Size: 1032 bytes --]

From 5378851c8bbdac5b3932aa8857b5b2878b31f2d3 Mon Sep 17 00:00:00 2001
From: Vincent Beffara <vbeffara@ens-lyon.fr>
Date: Thu, 7 Feb 2013 17:22:38 +0100
Subject: [PATCH] Fix the non-file-buffer bug

---
 lisp/ox-html.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index f4fc27b..67b5880 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -1992,10 +1992,10 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 ;;;; Latex Environment
 
 (defun org-html-format-latex (latex-frag processing-type)
-  (let* ((cache-relpath
+  (let* ((cache-relpath (ignore-errors
 	  (concat "ltxpng/" (file-name-sans-extension
-			     (file-name-nondirectory (buffer-file-name)))))
-	 (cache-dir (file-name-directory (buffer-file-name )))
+			     (file-name-nondirectory (buffer-file-name))))))
+	 (cache-dir (ignore-errors (file-name-directory (buffer-file-name ))))
 	 (display-msg "Creating LaTeX Image..."))
 
     (with-temp-buffer
-- 
1.7.12.4 (Apple Git-37)


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: Problem with org-html-format-latex
  2013-02-07 16:26 ` Vincent Beffara
@ 2013-02-08 18:49   ` Bastien
  2013-02-10 23:28     ` Vincent Beffara
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2013-02-08 18:49 UTC (permalink / raw)
  To: Vincent Beffara; +Cc: Org Mode List

Hi Vincent,

Vincent Beffara <vbeffara+ml@gmail.com> writes:

> Cleaner patch uses ignore-errors, that's simpler...

thanks for reporting this and for the patch, I've push 
a slightly different fix.  Please test and let me know.

Best,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Problem with org-html-format-latex
  2013-02-08 18:49   ` Bastien
@ 2013-02-10 23:28     ` Vincent Beffara
  2013-02-10 23:43       ` Vincent Beffara
  0 siblings, 1 reply; 9+ messages in thread
From: Vincent Beffara @ 2013-02-10 23:28 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode List

> thanks for reporting this and for the patch, I've push 
> a slightly different fix. Please test and let me know.

Sounds good to me, thanks!

/v 
> 
> Best,
> 
> -- 
> Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Problem with org-html-format-latex
  2013-02-10 23:28     ` Vincent Beffara
@ 2013-02-10 23:43       ` Vincent Beffara
  2013-02-11 15:12         ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Vincent Beffara @ 2013-02-10 23:43 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode List

> > thanks for reporting this and for the patch, I've push 
> > a slightly different fix. Please test and let me know.
> 
> Sounds good to me, thanks!

... well it did sound good to me, but it still fails. Put this in *scratch*,

(org-html-format-latex "x" 'mathjax)

and C-x C-e. Within org-format-latex, file-name-nondirectory is still called on the first argument (prefix) which your patch sets to nil. The error occurs one layer deeper in the tree but still does. My patch kind of fixed that by accident, but it should be safe at least in the case of mathjax which AFAICT will never create files anywhere - so simply testing on the value of processing-type would work better, maybe?

/v
> 
> /v 
> > 
> > Best,
> > 
> > -- 
> > Bastien
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Problem with org-html-format-latex
  2013-02-10 23:43       ` Vincent Beffara
@ 2013-02-11 15:12         ` Bastien
  2013-02-11 21:44           ` Vincent Beffara
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2013-02-11 15:12 UTC (permalink / raw)
  To: Vincent Beffara; +Cc: Org Mode List

Vincent Beffara <vbeffara+ml@gmail.com> writes:

> so simply testing
> on the value of processing-type would work better, maybe?

Yes, should be okay now, let me know!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Problem with org-html-format-latex
  2013-02-11 15:12         ` Bastien
@ 2013-02-11 21:44           ` Vincent Beffara
  2013-02-12  7:39             ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Vincent Beffara @ 2013-02-11 21:44 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode List

> > so simply testing
> > on the value of processing-type would work better, maybe?
> 
> Yes, should be okay now, let me know!

Nope, exactly the same. cache-relpath and cache-dir are not allowed to be nil. Meaning that if processing-type is 'mathjax they should be set to _some_ string anyway (the contents will be ignored eventually, but far down the line unfortunately ...) Something like instead of your 'let' line works:

(let ((cache-relpath "") (cache-dir "") bfn)

/v

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Problem with org-html-format-latex
  2013-02-11 21:44           ` Vincent Beffara
@ 2013-02-12  7:39             ` Bastien
  2013-02-12 20:26               ` Vincent Beffara
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2013-02-12  7:39 UTC (permalink / raw)
  To: Vincent Beffara; +Cc: Org Mode List

Vincent Beffara <vbeffara+ml@gmail.com> writes:

>> > so simply testing
>> > on the value of processing-type would work better, maybe?
>> 
>> Yes, should be okay now, let me know!
>
> Nope, exactly the same. cache-relpath and cache-dir are not allowed to be
> nil. Meaning that if processing-type is 'mathjax they should be set to
> _some_ string anyway (the contents will be ignored eventually, but far down
> the line unfortunately ...) Something like instead of your 'let' line
> works:
>
> (let ((cache-relpath "") (cache-dir "") bfn)

Mhh... okay.  Now should be good.  Thanks for your patience.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Problem with org-html-format-latex
  2013-02-12  7:39             ` Bastien
@ 2013-02-12 20:26               ` Vincent Beffara
  0 siblings, 0 replies; 9+ messages in thread
From: Vincent Beffara @ 2013-02-12 20:26 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode List

Hi, 
> > (let ((cache-relpath "") (cache-dir "") bfn)
> 
> Mhh... okay. Now should be good.

Yep, thanks! 
> Thanks for your patience.

No thanks needed, nor patience either for that matter, you and the other devs are the ones who should be thanked ...

/v
> 
> -- 
> Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-02-12 20:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-07 15:44 Problem with org-html-format-latex Vincent Beffara
2013-02-07 16:26 ` Vincent Beffara
2013-02-08 18:49   ` Bastien
2013-02-10 23:28     ` Vincent Beffara
2013-02-10 23:43       ` Vincent Beffara
2013-02-11 15:12         ` Bastien
2013-02-11 21:44           ` Vincent Beffara
2013-02-12  7:39             ` Bastien
2013-02-12 20:26               ` Vincent Beffara

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).