* [BUG] Set org-format-latex-options in .dir-locals.el [9.5.1 (release_9.5.1-11-g96d91b @ emacs-28.0.90/lisp/org/)]
@ 2021-12-17 12:55 Y. E. via General discussions about Org-mode.
2022-05-06 10:21 ` [PATCH] " Ihor Radchenko
0 siblings, 1 reply; 3+ messages in thread
From: Y. E. via General discussions about Org-mode. @ 2021-12-17 12:55 UTC (permalink / raw)
To: emacs-orgmode
Hello,
I tried configuring 'org-format-latex-options' per a org-mode
file/directory by adding the following configuration into the
.dir-locals.el file:
((org-mode . ((org-format-latex-options . (:foreground default
:background default
:scale 1.5
:html-foreground "#002277"
:html-background "Transparent"
:html-scale 1.0
:matchers ("begin" "\\(" "\\["))))))
When I load the org file, I'm being asked if I'd like to load local
variables, so I agree on that.
After that, 'C-h v org-format-latex-options' outputs:
Value:
(:foreground default :background default :scale 1.5 :html-foreground "#002277" :html-background "Transparent" :html-scale 1.0 :matchers
("begin" "\\(" "\\["))
Original value was
(:foreground default :background default :scale 1.0 :html-foreground "Black" :html-background "Transparent" :html-scale 1.0 :matchers
("begin" "$1" "$" "$$" "\\(" "\\["))
Local in buffer Notes/Blog/concrete-math.org; global value is
(:foreground default :background default :scale 1.0 :html-foreground "Black" :html-background "Transparent" :html-scale 1.0 :matchers
("begin" "$1" "$" "$$" "\\(" "\\["))
Then I do 'M-x org-html-export-to-html' to see that custom/local
settings are not taken into an account: an exported HTML contains SVGs
corresponding to the default settings.
The file settings I use:
#+STARTUP: content latexpreview
#+OPTIONS: tex:dvisvgm html-style:nil
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style.css" />
The LaTeX formulas are embedded into the text as shown here:
https://orgmode.org/manual/LaTeX-fragments.html
Am I overlooking something?
(Setting the value of 'org-format-latex-options' *globally* results in
expected behavior.)
I didn't have a chance to look deeper, but this mailing list discussion
might be related:
https://lists.gnu.org/archive/html/emacs-orgmode/2019-11/msg00050.html
Thanks,
YE
Emacs : GNU Emacs 28.0.90 (build 1, x86_64-apple-darwin21.1.0, NS appkit-2113.00 Version 12.0.1 (Build 21A559))
of 2021-12-03
Package: Org mode version 9.5.1 (release_9.5.1-11-g96d91b @ /Users/yuga/Downloads/emacs-28.0.90/lisp/org/)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Re: [BUG] Set org-format-latex-options in .dir-locals.el [9.5.1 (release_9.5.1-11-g96d91b @ emacs-28.0.90/lisp/org/)]
2021-12-17 12:55 [BUG] Set org-format-latex-options in .dir-locals.el [9.5.1 (release_9.5.1-11-g96d91b @ emacs-28.0.90/lisp/org/)] Y. E. via General discussions about Org-mode.
@ 2022-05-06 10:21 ` Ihor Radchenko
2022-07-20 7:14 ` Ihor Radchenko
0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2022-05-06 10:21 UTC (permalink / raw)
To: Y. E., Nicolas Goaziou; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 935 bytes --]
Y. E. via "General discussions about Org-mode." <emacs-orgmode@gnu.org>
writes:
> Hello,
>
> I tried configuring 'org-format-latex-options' per a org-mode
> file/directory by adding the following configuration into the
> .dir-locals.el file:
> The file settings I use:
>
> #+STARTUP: content latexpreview
> #+OPTIONS: tex:dvisvgm html-style:nil
> #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style.css" />
>
> The LaTeX formulas are embedded into the text as shown here:
> https://orgmode.org/manual/LaTeX-fragments.html
>
> Am I overlooking something?
Nope. This is a bug.
It happens because LaTeX fragments are processed in temporary buffer and
all the buffer-local variables you set in the original org buffer are
discarded.
The fix is attached.
Nicolas, this kind of error might be present in various places of export
library. You may want to fix it in more places than what I propose in
this patch.
Best,
Ihor
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-html-format-latex-Preserve-buffer-local-settings.patch --]
[-- Type: text/x-patch, Size: 1565 bytes --]
From 37a37862a17c4b333164edffbac97f8a56052e88 Mon Sep 17 00:00:00 2001
Message-Id: <37a37862a17c4b333164edffbac97f8a56052e88.1651832231.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Fri, 6 May 2022 18:14:05 +0800
Subject: [PATCH] org-html-format-latex: Preserve buffer-local settings
* lisp/ox-html.el (org-html-format-latex): Carry over buffer-local
variables when create LaTeX images. Use `org-export-with-buffer-copy'
instead of `with-temp-buffer'.
Fixes https://orgmode.org/list/m2fsqr75md.fsf@ego.team
---
lisp/ox-html.el | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 81ef002a0..7f2087a46 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2872,11 +2872,12 @@ (defun org-html-format-latex (latex-frag processing-type info)
;; temporary buffer so that dvipng/imagemagick can properly
;; turn the fragment into an image.
(setq latex-frag (concat latex-header latex-frag))))
- (with-temp-buffer
- (insert latex-frag)
- (org-format-latex cache-relpath nil nil cache-dir nil
- "Creating LaTeX Image..." nil processing-type)
- (buffer-string))))
+ (org-export-with-buffer-copy
+ (erase-buffer)
+ (insert latex-frag)
+ (org-format-latex cache-relpath nil nil cache-dir nil
+ "Creating LaTeX Image..." nil processing-type)
+ (buffer-string))))
(defun org-html--wrap-latex-environment (contents _ &optional caption label)
"Wrap CONTENTS string within appropriate environment for equations.
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-20 7:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-17 12:55 [BUG] Set org-format-latex-options in .dir-locals.el [9.5.1 (release_9.5.1-11-g96d91b @ emacs-28.0.90/lisp/org/)] Y. E. via General discussions about Org-mode.
2022-05-06 10:21 ` [PATCH] " Ihor Radchenko
2022-07-20 7:14 ` Ihor Radchenko
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.