emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Feng Shu <tumashu@163.com>
Cc: orgmode-devel <emacs-orgmode@gnu.org>
Subject: Re: (version 3) [PATCH] New feature: Use dvisvgm to preview latex formular
Date: Mon, 16 May 2016 00:32:18 +0200	[thread overview]
Message-ID: <87inyfuf4d.fsf@saiph.selenimh> (raw)
In-Reply-To: <87posncycg.fsf@163.com> (Feng Shu's message of "Sun, 15 May 2016 20:14:23 +0800")

Hello,

"Feng Shu" <tumashu@163.com> writes:

Thank you for this work. This looks interesting. Some comments follow.

> * ox-latex.el (org-latex-pdf-process): Add a new config
> method, :fetcher.

At this point, I think we should instead separate compiler for LaTeX
preview from compiler for full LaTeX export. It probably makes sense to
have a full fledged compile process for the export back-end possibly
with multiple passes to get cross-references right, and a quick process
for previews.

In any case, I suggest to create a new variable
`org-latex-preview-process' for that.

> (org-latex-compile): Add a new optional argument: caller-info,
>                      which used to record the caller's info

In the same vein, I suggest to extract it out from ox-latex and use
a dedicated command for that.

WDYT?

> (org-create-formula-image): Big refactor, merge dvipng and imagemagick backend's feature.
>                             Add dvisvgm feature.

Good news. This part was begging for a refactor. A couple (or more) of
tests would be nice too.

> -(defcustom org-latex-preview-ltxpng-directory "ltxpng/"
> +(defcustom org-latex-to-image-backends
> +  '((dvipng
> +     :class snippet
> +     :name dvipng
> +     :programs ("dvipng" "gs")
> +     :message "you need to install dvipng and ghostscript."
> +     :input dvi
> +     :output png
> +     :color dvipng
> +     :scale-adjust 2.0
> +     :org-latex-compile nil
> +     :need-clean (".dvi" ".tex" ".aux" ".log" ".png" ".out")
> +     :commands (("latex" "-interaction" "nonstopmode" "-output-directory" "%temp-dir%" "%tex-file%")
> +		("dvipng" "-fg" "%fg%" "-bg" "%bg%" "-D" "%dpi%" "-T" "tight" "-o" "%output-file%" "%input-file%")))
> +    (dvisvgm
> +     :class snippet
> +     :name dvisvgm
> +     :programs ("dvisvgm" "gs")
> +     :message "you needed to install dvisvgm and ghostscript."
> +     :input dvi
> +     :output svg
> +     :color latex
> +     :scal-adjust 2.0

Typo. :scale-adjust

> +     :org-latex-compile t
> +     :post-clean (".dvi" ".xdv" ".tex" ".aux" ".log" ".svg" ".out")
> +     :commands (("dvisvgm" "%input-file%" "-n" "-b" "min" "-c" "%scale%" "-o" "%output-file%")))
> +    (imagemagick
> +     :class snippet
> +     :name imagemagick
> +     :programs ("convert" "gs")
> +     :message "you need to install imagemagick and ghostscript."
> +     :input pdf
> +     :output png
> +     :color latex
> +     :scale-adjust 2.0
> +     :org-latex-compile t
> +     :post-clean (".pdf" ".tex" ".aux" ".log" ".png" ".out")
> +     :commands (("convert" "-density" "%dpi%" "-trim" "-antialias" "%input-file%" "-quality" "100" "%output-file%"))))
> +  "Org mode can use some external commands to generate TeX snippet's image for

The first line needs to be a sentence on its own. Perhaps:

  "List definitions of external processes for LaTeX previewing.
Org can use some external commands to generate LaTeX snippet' images for
..."

> +proviewing or inserting to html file, for example: dvipng, dvisvgm or imagemagick

previewing or inserting into HTML files, e.g.,

> +this variable tell `org-create-formula-image' how to use the above command.

tells

> +  :class              symbol, this setting may useful in future.

may be useful

> +  :name               string, the backend's name.
> +  :programs           string-list, required programs.

list of strings

> +  :message            string, message it when required program can't be found.
> +  :input              symbol, input file type, for example: dvi.
> +  :output             symbol, output file type, for example: png.
> +  :color              symbol, if it set to 'latex, latex xcolor macro will be used

if set to `latex', LaTeX "xcolor" macro is used

> +                      to deal with background and fontground color of image, 'divpng

if set to `dvipng'

> +                      is only useful to dvipng backend.
> +  :scale-adjust       number, adjust image's size, only useful for backend developers.
> +  :org-latex-compile  boolean, if set it to t, `org-create-formula-image' will use

when non-nil `org-create-formula-image' uses...

> +                      `org-latex-compile' to compile tex file, when set it to nil,

otherwise, you need to

> +                      user need to set latex command in `:commands'.
> +  :need-clean         string-list, the files matched its elements will be cleaned up
> +                      after image generated.

list of strings, files matched are to be cleaned up once the image is
generated

> +  :commands           list, the commands setting, the following special strings,
> +                      will be replaced to according value before command called.
> +
> +       	              1. %fg%            fontground

foreground

> +                      For example, %tmpdir% may be replaced to /tmp in linux."

may be replaced with "/tmp".

> +  :group 'org-latex
> +  :version "24.1"

:version "25.1"

> +  :type 'alist)

The type should reflect the complexity of the value.

> +
> +(defalias 'org-latex-preview-ltxpng-directory 'org-latex-preview-ltximg-directory)
> +(make-obsolete 'org-latex-preview-ltxpng-directory 'org-latex-preview-ltximg-directory
> +	       "Org mode version 9.0")

See `make-obsolete-variable'.

> +		   (let* ((backend-info
> +			   (cdr (assoc processing-type org-latex-to-image-backends)))

`assoc' -> `assq'

> +  (let* ((type (or type 'dvipng))
> +	 (backend-info
> +	  (cdr (assoc type org-latex-to-image-backends)))

`assq'

> +	 (tmpdir (if (featurep 'xemacs)
>  		     (temp-directory)
>  		   temporary-file-directory))

You can drop this, Org 9 doesn't support XEmacs anyway.

> +    (dolist (command commands)
> +      (let ((command
> +	     (mapcar #'(lambda (c)

No need to use #' for lambda.

> +			 (dolist (arg args-alist)
> +			   (setq c (replace-regexp-in-string
> +				    (car arg) (cdr arg) c)))
> +			 c) command)))
> +	;; (princ args-alist)
> +	;; (princ command)

Please remove debugging comments.

> +	(ignore-errors
> +	  (apply 'call-process

Nitpick: #'call-process


Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2016-05-15 22:32 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-14  6:30 [PATCH] New feature: Use dvisvgm to preview latex formular Feng Shu
2016-05-14  8:47 ` numbchild
2016-05-14 14:56 ` Feng Shu
2016-05-15  2:27   ` Feng Shu
2016-05-15  6:02   ` (version 3) " Feng Shu
2016-05-15 12:14     ` Feng Shu
2016-05-15 22:32       ` Nicolas Goaziou [this message]
2016-05-16  5:32         ` Feng Shu
2016-05-16 13:18           ` Nicolas Goaziou
2016-05-16 15:06             ` tumashu
2016-05-16  5:33         ` Feng Shu
2016-05-16 13:19           ` Nicolas Goaziou
2016-05-16 12:05         ` (v6) " Feng Shu
2016-05-16 21:17           ` Nicolas Goaziou
2016-05-16 22:17             ` tumashu
2016-05-17  1:15             ` tumashu
2016-05-18  6:30             ` (V8) " Feng Shu
2016-05-19  8:22               ` Nicolas Goaziou
2016-05-19  9:18                 ` tumashu
2016-05-19 10:32                   ` Nicolas Goaziou
2016-05-19 14:01                     ` (V9) " Feng Shu
2016-05-21  9:38                       ` Nicolas Goaziou
2016-05-21 12:22                         ` Feng Shu
2016-05-21 13:35                           ` Rasmus
2016-05-15 12:16     ` (version 4) " Feng Shu

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=87inyfuf4d.fsf@saiph.selenimh \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=tumashu@163.com \
    /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).