emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Patch] Do not ignore headers argument in ob-latex
@ 2020-05-06 20:04 Yuri Lensky
  2020-05-07 20:09 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Yuri Lensky @ 2020-05-06 20:04 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 80 bytes --]

ob-latex default .png export completely ignored additional "headers"
arguments.

[-- Attachment #1.2: Type: text/html, Size: 111 bytes --]

[-- Attachment #2: 0001-lisp-ob-latex.el-Stop-ignoring-headers-argument.patch --]
[-- Type: application/octet-stream, Size: 1217 bytes --]

From 17af816d93da93313e5b8caf661fa2dad5439f15 Mon Sep 17 00:00:00 2001
From: "Yuri D. Lensky" <ydl@ydl.cm>
Date: Wed, 6 May 2020 12:50:11 -0700
Subject: [PATCH] lisp/ob-latex.el: Stop ignoring headers argument

During default "png" export, the "headers" argument is no longer
explicitly ignored.
---
 lisp/ob-latex.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el
index 2376b987b..677da79c0 100644
--- a/lisp/ob-latex.el
+++ b/lisp/ob-latex.el
@@ -109,8 +109,11 @@ This function is called by `org-babel-execute-src-block'."
 	      (append (cdr (assq :packages params)) org-latex-packages-alist)))
         (cond
          ((and (string-suffix-p ".png" out-file) (not imagemagick))
-          (org-create-formula-image
-           body out-file org-format-latex-options in-buffer))
+          (let ((org-format-latex-header
+		 (concat org-format-latex-header "\n"
+			 (string-join headers "\n"))))
+	   (org-create-formula-image
+            body out-file org-format-latex-options in-buffer)))
          ((string-suffix-p ".tikz" out-file)
 	  (when (file-exists-p out-file) (delete-file out-file))
 	  (with-temp-file out-file
-- 
2.26.2.windows.1


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

* Re: [Patch] Do not ignore headers argument in ob-latex
  2020-05-06 20:04 [Patch] Do not ignore headers argument in ob-latex Yuri Lensky
@ 2020-05-07 20:09 ` Nicolas Goaziou
  2020-05-09 20:12   ` Yuri Lensky
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2020-05-07 20:09 UTC (permalink / raw)
  To: Yuri Lensky; +Cc: emacs-orgmode

Hello,

Yuri Lensky <ydl@ydl.cm> writes:

> Subject: [PATCH] lisp/ob-latex.el: Stop ignoring headers argument

Thank you.

> During default "png" export, the "headers" argument is no longer
> explicitly ignored.

According to the TODO in that function, this is not the first time it
happens. Would you mind writing a test for it?

> +          (let ((org-format-latex-header
> +		 (concat org-format-latex-header "\n"
> +			 (string-join headers "\n"))))
> +	   (org-create-formula-image
> +            body out-file org-format-latex-options in-buffer)))

This looks hackish but I don't know how to do it otherwise. However
could you use `mapconcat' instead of `string-join'?

Also, you need to declare `org-format-latex-header' in order to silence
byte-compiler.

Regards,

-- 
Nicolas Goaziou


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

* Re: [Patch] Do not ignore headers argument in ob-latex
  2020-05-07 20:09 ` Nicolas Goaziou
@ 2020-05-09 20:12   ` Yuri Lensky
  2020-05-10 12:56     ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Yuri Lensky @ 2020-05-09 20:12 UTC (permalink / raw)
  To: Yuri Lensky, emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1387 bytes --]

Hi,

I have updated the attached patch to use `mapconcat' as requested.
`org-format-latex-header' is already declared earlier in ob-latex.el.

I am not sure what kind of test you have in mind, since this feature isn't
completely internal to org-mode. For example, the preview compiles but the
produced PDF is incorrect before this fix, and I believe the org preview
machinery ignores errors from the latex compiler.

Best,

YL

On Thu, May 7, 2020 at 1:37 PM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Yuri Lensky <ydl@ydl.cm> writes:
>
> > Subject: [PATCH] lisp/ob-latex.el: Stop ignoring headers argument
>
> Thank you.
>
> > During default "png" export, the "headers" argument is no longer
> > explicitly ignored.
>
> According to the TODO in that function, this is not the first time it
> happens. Would you mind writing a test for it?
>
> > +          (let ((org-format-latex-header
> > +              (concat org-format-latex-header "\n"
> > +                      (string-join headers "\n"))))
> > +        (org-create-formula-image
> > +            body out-file org-format-latex-options in-buffer)))
>
> This looks hackish but I don't know how to do it otherwise. However
> could you use `mapconcat' instead of `string-join'?
>
> Also, you need to declare `org-format-latex-header' in order to silence
> byte-compiler.
>
> Regards,
>
> --
> Nicolas Goaziou
>

[-- Attachment #1.2: Type: text/html, Size: 2043 bytes --]

[-- Attachment #2: 0001-lisp-ob-latex.el-Stop-ignoring-headers-argument.patch --]
[-- Type: application/octet-stream, Size: 1226 bytes --]

From f6cda0212fd2286d43b8f4e617a3e39c0e8c070d Mon Sep 17 00:00:00 2001
From: "Yuri D. Lensky" <ydl@ydl.cm>
Date: Wed, 6 May 2020 12:50:11 -0700
Subject: [PATCH] lisp/ob-latex.el: Stop ignoring headers argument

During default "png" export, the "headers" argument is no longer
explicitly ignored.
---
 lisp/ob-latex.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el
index 2376b987b..4b343dd14 100644
--- a/lisp/ob-latex.el
+++ b/lisp/ob-latex.el
@@ -109,8 +109,11 @@ This function is called by `org-babel-execute-src-block'."
 	      (append (cdr (assq :packages params)) org-latex-packages-alist)))
         (cond
          ((and (string-suffix-p ".png" out-file) (not imagemagick))
-          (org-create-formula-image
-           body out-file org-format-latex-options in-buffer))
+          (let ((org-format-latex-header
+		 (concat org-format-latex-header "\n"
+			 (mapconcat #'identity headers "\n"))))
+	   (org-create-formula-image
+            body out-file org-format-latex-options in-buffer)))
          ((string-suffix-p ".tikz" out-file)
 	  (when (file-exists-p out-file) (delete-file out-file))
 	  (with-temp-file out-file
-- 
2.26.2.windows.1


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

* Re: [Patch] Do not ignore headers argument in ob-latex
  2020-05-09 20:12   ` Yuri Lensky
@ 2020-05-10 12:56     ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2020-05-10 12:56 UTC (permalink / raw)
  To: Yuri Lensky; +Cc: emacs-orgmode

Hello,

Yuri Lensky <ydl@ydl.cm> writes:

> I have updated the attached patch to use `mapconcat' as requested.
> `org-format-latex-header' is already declared earlier in ob-latex.el.

I fixed the commit message and applied the patch. Thank you.

> I am not sure what kind of test you have in mind, since this feature isn't
> completely internal to org-mode. For example, the preview compiles but the
> produced PDF is incorrect before this fix, and I believe the org preview
> machinery ignores errors from the latex compiler.

I was thinking about regression testing `org-babel-execute:latex'. But
it may not make much sense, indeed.

Regards,

-- 
Nicolas Goaziou


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

end of thread, other threads:[~2020-05-10 12:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-06 20:04 [Patch] Do not ignore headers argument in ob-latex Yuri Lensky
2020-05-07 20:09 ` Nicolas Goaziou
2020-05-09 20:12   ` Yuri Lensky
2020-05-10 12:56     ` Nicolas Goaziou

Code repositories for project(s) associated with this 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).