From: Carlos Pita <carlosjosepita@gmail.com>
To: Carlos Pita <carlosjosepita@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)]
Date: Thu, 3 Jan 2019 12:38:00 -0300 [thread overview]
Message-ID: <CAELgYhdunfwEPYgZPTk9YeNw2t9=0eSuRs4+idXUDj++qMAOGQ@mail.gmail.com> (raw)
In-Reply-To: <87ef9uug73.fsf@nicolasgoaziou.fr>
[-- Attachment #1: Type: text/plain, Size: 392 bytes --]
Hi Nicolas,
I've improved the commit message to better fit org mode conventions
and also added a note to ORG-NEWS about the new feature. Let me know
if there still is something I should change or feel free to amend it
to your liking.
One question for future patches: is it ok to add a link to the mailing
list thread where the issue was discussed in the commit message?
Regards
--
Carlos.
[-- Attachment #2: 0001-Use-xcolor-for-all-latex-preview-converters.patch --]
[-- Type: text/x-patch, Size: 6647 bytes --]
From bc210a028bb755aa8ca0eaef1605efaab735fde4 Mon Sep 17 00:00:00 2001
From: memeplex <carlosjosepita@gmail.com>
Date: Wed, 2 Jan 2019 19:05:26 -0300
Subject: [PATCH] Use xcolor for all latex preview converters
* lisp/org.el: remove :use-xcolor option and make dvipng use xcolor
since usage of CLI fg and bg color args is incompatible with docs
that themselves use xcolor (e.g. through tikz).
* etc/ORG-NEWS: add incompatible change note.
---
etc/ORG-NEWS | 9 ++++++++
lisp/org.el | 63 ++++++++++++++++------------------------------------
2 files changed, 28 insertions(+), 44 deletions(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index b988559..c1e426c 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -39,6 +39,15 @@ arguments no longer imply a "file" result is expected.
See [[git:3367ac9457]] for details.
+*** All LaTeX preview backends use now xcolor
+
+The dvipng backend was previously relying on fg and bg parameters to
+be passed to the CLI. This didn't work when xcolor was directly or
+indirectly used in the document (e.g. tkiz is a user of xcolor). Since
+every other backend was already using xcolor to set fg and bg, the CLI
+alternative was removed and there is no more a :use-xcolor options
+since now it's implicitly always true.
+
** New features
*** Add a dispatcher command to insert dynamic blocks
diff --git a/lisp/org.el b/lisp/org.el
index 0e541cd..2e63a65 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3813,12 +3813,11 @@ All available processes and theirs documents can be found in
:image-output-type "png"
:image-size-adjust (1.0 . 1.0)
:latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
- :image-converter ("dvipng -fg %F -bg %B -D %D -T tight -o %O %f"))
+ :image-converter ("dvipng -D %D -T tight -o %O %f"))
(dvisvgm
:programs ("latex" "dvisvgm")
:description "dvi > svg"
:message "you need to install the programs: latex and dvisvgm."
- :use-xcolor t
:image-input-type "dvi"
:image-output-type "svg"
:image-size-adjust (1.7 . 1.5)
@@ -3828,7 +3827,6 @@ All available processes and theirs documents can be found in
:programs ("latex" "convert")
:description "pdf > png"
:message "you need to install the programs: latex and imagemagick."
- :use-xcolor t
:image-input-type "pdf"
:image-output-type "png"
:image-size-adjust (1.0 . 1.0)
@@ -3848,11 +3846,6 @@ PROPERTIES accepts the following attributes:
:message string, message it when required programs cannot be found.
:image-input-type string, input file type of image converter (e.g., \"dvi\").
:image-output-type string, output file type of image converter (e.g., \"png\").
- :use-xcolor boolean, when non-nil, LaTeX \"xcolor\" macro is used to
- deal with background and foreground color of image.
- Otherwise, dvipng style background and foreground color
- format are generated. You may then refer to them in
- command options with \"%F\" and \"%B\".
:image-size-adjust cons of numbers, the car element is used to adjust LaTeX
image size showed in buffer and the cdr element is for
HTML file. This option is only useful for process
@@ -3884,8 +3877,6 @@ Place-holders used by `:image-converter' and `:latex-compiler':
Place-holders only used by `:image-converter':
- %F foreground of image
- %B background of image
%D dpi, which is used to adjust image size by some processing commands.
%S the image size scale ratio, which is used to adjust image size by some
processing commands."
@@ -18339,7 +18330,6 @@ a HTML file."
(cdr (assq processing-type org-preview-latex-process-alist)))
(programs (plist-get processing-info :programs))
(error-message (or (plist-get processing-info :message) ""))
- (use-xcolor (plist-get processing-info :use-xcolor))
(image-input-type (plist-get processing-info :image-input-type))
(image-output-type (plist-get processing-info :image-output-type))
(post-clean (or (plist-get processing-info :post-clean)
@@ -18370,36 +18360,23 @@ a HTML file."
(resize-mini-windows nil)) ;Fix Emacs flicker when creating image.
(dolist (program programs)
(org-check-external-command program error-message))
- (if use-xcolor
- (progn (if (eq fg 'default)
- (setq fg (org-latex-color :foreground))
- (setq fg (org-latex-color-format fg)))
- (if (eq bg 'default)
- (setq bg (org-latex-color :background))
- (setq bg (org-latex-color-format
- (if (string= bg "Transparent") "white" bg))))
- (with-temp-file texfile
- (insert latex-header)
- (insert "\n\\begin{document}\n"
- "\\definecolor{fg}{rgb}{" fg "}\n"
- "\\definecolor{bg}{rgb}{" bg "}\n"
- "\n\\pagecolor{bg}\n"
- "\n{\\color{fg}\n"
- string
- "\n}\n"
- "\n\\end{document}\n")))
- (if (eq fg 'default)
- (setq fg (org-dvipng-color :foreground))
- (unless (string= fg "Transparent")
- (setq fg (org-dvipng-color-format fg))))
- (if (eq bg 'default)
- (setq bg (org-dvipng-color :background))
- (unless (string= bg "Transparent")
- (setq bg (org-dvipng-color-format bg))))
- (with-temp-file texfile
- (insert latex-header)
- (insert "\n\\begin{document}\n" string "\n\\end{document}\n")))
-
+ (if (eq fg 'default)
+ (setq fg (org-latex-color :foreground))
+ (setq fg (org-latex-color-format fg)))
+ (if (eq bg 'default)
+ (setq bg (org-latex-color :background))
+ (setq bg (org-latex-color-format
+ (if (string= bg "Transparent") "white" bg))))
+ (with-temp-file texfile
+ (insert latex-header)
+ (insert "\n\\begin{document}\n"
+ "\\definecolor{fg}{rgb}{" fg "}\n"
+ "\\definecolor{bg}{rgb}{" bg "}\n"
+ "\n\\pagecolor{bg}\n"
+ "\n{\\color{fg}\n"
+ string
+ "\n}\n"
+ "\n\\end{document}\n"))
(let* ((err-msg (format "Please adjust `%s' part of \
`org-preview-latex-process-alist'."
processing-type))
@@ -18409,9 +18386,7 @@ a HTML file."
(image-output-file
(org-compile-file
image-input-file image-converter image-output-type err-msg log-buf
- `((?F . ,(shell-quote-argument fg))
- (?B . ,(shell-quote-argument bg))
- (?D . ,(shell-quote-argument (format "%s" dpi)))
+ `((?D . ,(shell-quote-argument (format "%s" dpi)))
(?S . ,(shell-quote-argument (format "%s" (/ dpi 140.0))))))))
(copy-file image-output-file tofile 'replace)
(dolist (e post-clean)
--
2.20.1
next prev parent reply other threads:[~2019-01-03 15:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-05 19:17 Bug: Latex preview fg color w/tikz (known problem, fix suggested) [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.90/lisp/org/)] Carlos Pita
2018-12-05 19:37 ` Carlos Pita
2018-12-05 23:38 ` Nicolas Goaziou
2018-12-08 4:32 ` Carlos Pita
2018-12-08 9:56 ` Nicolas Goaziou
2018-12-08 14:43 ` Eric S Fraga
2018-12-22 14:00 ` Carlos Pita
2019-01-01 18:08 ` Carlos Pita
2019-01-02 15:07 ` Nicolas Goaziou
2019-01-02 22:12 ` Carlos Pita
2019-01-03 11:35 ` Nicolas Goaziou
2019-01-03 15:38 ` Carlos Pita [this message]
2019-01-04 13:21 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAELgYhdunfwEPYgZPTk9YeNw2t9=0eSuRs4+idXUDj++qMAOGQ@mail.gmail.com' \
--to=carlosjosepita@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 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.