emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] (version 3) [PATCH] New feature: Use dvisvgm to preview latex fo


From: Nicolas Goaziou
Subject: Re: [O] (version 3) [PATCH] New feature: Use dvisvgm to preview latex formular
Date: Mon, 16 May 2016 00:32:18 +0200

Hello,

"Feng Shu" <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]