Re: [O] (V8) [PATCH] New feature: Use dvisvgm to preview latex formular

2016-05-19 Thread Nicolas Goaziou
tumashu   writes:

>   `((?b . ,(shell-quote-argument base-name))
>(?f . ,(shell-quote-argument full-name))
>   (?o . ,(shell-quote-argument out-dir))
>
>
> What about add a  spec to  output-file, some commands need this
> information.

I'm not sure to understand. What information do you need?

Regards,



Re: [O] (V8) [PATCH] New feature: Use dvisvgm to preview latex formular

2016-05-19 Thread tumashu
  `((?b . ,(shell-quote-argument base-name))
   (?f . ,(shell-quote-argument full-name))
  (?o . ,(shell-quote-argument out-dir))


What about add a  spec to  output-file, some commands need this information.
I will edit my diff tonight and sent to org-mode mailling list as far as 
possible.




Re: [O] (V8) [PATCH] New feature: Use dvisvgm to preview latex formular

2016-05-19 Thread Nicolas Goaziou
Hello,

"Feng Shu"  writes:

> I have rebase my patch to new function org-compile-file, the v8 patch is
> very different with the earlier version, it is more simpler i think,
> please comment again, thanks for your help!

Thank you. I added `org-compile-file' to master branch and incorporated
some of you suggestions. Beware, however, that there are some
differences with the version you're using here. In particular, 

1. the order of arguments is different;
2. %b, %f, and %o are always replaced in commands, no need to specify
   them again when using argument SPEC;
3. extension argument is a string, not a symbol or a list of symbols.

By the way, I don't understand why you do need to provide a list of
extensions. The extension argument is used to check if the process
actually succeeded, but the process itself can create as many files as
it sees fit.

Some additional comments follow.

> +(dvisvgm
> + :programs ("latex" "dvisvgm" "gs")
> + :message "you needed to install latex, dvisvgm and ghostscript."
> + :use-xcolor t
> + :image-input (dvi xdv)

Per above, it is either dvi or xdv

> +  "List definitions of external processes for LaTeX previewing.
> +Org mode can use some external commands to generate TeX snippet's image for
> +previewing or inserting into HTML files, e.g. dvipng, dvisvgm or imagemagick.
> +This variable tells `org-create-formula-image' how to use external commands.
> +
> +  :name   symbol, the process setting name.
> +  :inheritsymbol, inhert options from an exist process setting.

I suggest to drop the property above. It is only partially implemented
(e.g., you cannot inherit from an inherited process), it complicates
code, and I don't think it is terribly useful overall.

> +  :image-inputsymbol, input file type, for example: dvi.
> +  :image-output   symbol, output file type, for example: png.

symbol -> string

> +  :use-xcolor boolean, if set to `t', LaTeX \"xcolor\" macro is used
> +  to deal with background and foreground color of image,
> +  if set to `nil', dvipng style background and foregroud 
> color
> +  format are generated; you should used them in command 
> options
> +  with special string: \"%F\" and \"%B\".

when non-nil, `LaTeX' \"xcolor\"... color of image.  Otherwise, dvipng
style... 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

latex -> LaTeX

> +  size showed in buffer and the cdr element is for html 
> file.

html -> HTML

> +  This option is only useful for backend developers, 
> users
> +  should use variable `org-format-latex-options' instead.
> +  :post-clean list of strings, files matched are to be cleaned up 
> once the
> +  image is generated. If set to `nil', the files with 
> dvi, xdv,
> +  pdf, tex, aux, log, svg, png, jpg, jpeg or out 
> extension will
> +  be cleaned up.
> +  :latex-header   list of string, latex snippet file's header, if set to 
> `nil',

latex -> `LaTeX'

> +  the return value of `org-create-formula--latex-header' 
> will be
> +  used, which is controled `org-format-latex-header',
> +  `org-latex-default-packages-alist' and 
> `org-latex-packages-alist'.

No need to reference an internal function:

  the return value is controlled by `org-format-latex-header'
  `org-latex-default-packages-alist' and `org-latex-packages-alist',
  which see.

> +  :latex-compiler list of latex commands, each of them will be given to 
> the shell
> +  as a command.  the special strings, %t, %b and %o, 
> will be replaced
> +  to according value before commands called.

as a command.  Place-holders "%t", "%b" and "%o" are replaced with
values defined below.

> +  :image-converterlist of image converter command strings, each of them 
> will be
> +  given to the shell as a command.  the following 
> special strings,
> +  will be replaced to according value before commands 
> called.

each of them is given to the shell as a command and support any of the
following place-holders defined below.

> +Special strings used by `:image-converter' and `:latex-compiler':

Place-holders used by...

> +5. %ttex file name.

Couldn't you use %f so as to be compatible with default place-holders?

> -(defun org--format-latex-make-overlay (beg end image)
> +(defun org--format-latex-make-overlay (beg end image  imagetype)
>"Build an overlay between BEG and END using IMAGE file."

You need to explain IMAGETYPE in docstring, e.g.,

  Argument IMAGETYPE is the extension of the displayed image, as
  a symbol. It 

Re: [O] (V8) [PATCH] New feature: Use dvisvgm to preview latex formular

2016-05-18 Thread Feng Shu

> As discussed in another message, I don't think we should mess with
> `org-latex-compile'. Instead, we could factor out the needed part in
> `org-latex-compile' and make it a generic function. Then we can
> introduce a new function to specifically handle previewing related
> compilation.
>
> Note that I'm not asking you to implement the factoring out part in your
> patch, but to tell me if the following would fulfill your needs for
> `org-create-formula-image'. I'm sending its docstring again.
>

I have rebase my patch to new function org-compile-file, the v8 patch is
very different with the earlier version, it is more simpler i think,
please comment again, thanks for your help!


>From 61885684f4826b06de4bb72b6ef1f369960f268a Mon Sep 17 00:00:00 2001
From: Feng Shu 
Date: Tue, 17 May 2016 21:24:35 +0800
Subject: [PATCH] New feature: Use dvisvgm to preview latex formular

* ox-html.el (org-html-with-latex): Add dvisvgm support.
(org-html-with-latex): Add dvisvgm support.
(org-html-format-latex): "ltxpng" -> "ltximg".
(org-html-latex-environment): Add dvisvgm support.
(org-html-latex-fragment): Add dvisvgm support.

* org.el (org-latex-create-formula-image-program): Add dvisvgm.
(org-latex-preview-ltximg-directory): Rename from `org-preview-latex-image-directory'.
(org--format-latex-make-overlay): Add optional image-type, which used to deal with svg.
(org-toggle-latex-fragment): "org-ltxpng" -> "org-ltximg".
(org-format-latex): Add dvisvgm support.
(org-create-formula-image): Big refactor, merge dvipng and imagemagick backend's feature.
Add dvisvgm feature.
(org-preview-latex-process-alist): Add new variable, which used to set
   latex preview processes.
(org-create-formula-image-with-dvipng): Useless, removed.
(org-create-formula-image-with-imagemagick): Useless, removed.

* org.texi (@LaTeX{} fragments): Add dvisvgm information.
(Previewing @LaTeX{} fragments): Add dvisvgm information.
(Math formatting in HTML export): Add dvisvgm information.
(Working with @LaTeX{} math snippets): Add dvisvgm information.
---
 doc/org.texi|  41 +++--
 lisp/org.el | 462 +---
 lisp/ox-html.el |  27 ++--
 3 files changed, 346 insertions(+), 184 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 17b01c2..ad75b5d 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -10393,10 +10393,10 @@ snippets will be identified as @LaTeX{} source code:
 @item
 Environments of any kind@footnote{When MathJax is used, only the
 environments recognized by MathJax will be processed.  When
-@file{dvipng} program or @file{imagemagick} suite is used to create images,
-any @LaTeX{} environment will be handled.}.  The only requirement is that the
-@code{\begin} statement appears on a new line, at the beginning of the line
-or after whitespaces only.
+@file{dvipng} program, @file{dvisvgm} program or @file{imagemagick} suite is
+used to create images, any @LaTeX{} environment will be handled.}.  The only
+requirement is that the @code{\begin} statement appears on a new line, at the
+beginning of the line or after whitespaces only.
 @item
 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts with
 currency specifications, single @samp{$} characters are only recognized as
@@ -10444,11 +10444,11 @@ lines:
 @cindex @LaTeX{} fragments, preview
 
 @vindex org-latex-create-formula-image-program
-If you have a working @LaTeX{} installation and either @file{dvipng} or
-@file{convert} installed@footnote{These are respectively available at
-@url{http://sourceforge.net/projects/dvipng/} and from the @file{imagemagick}
-suite. Choose the converter by setting the variable
-@code{org-latex-create-formula-image-program} accordingly.}, @LaTeX{}
+If you have a working @LaTeX{} installation and @file{dvipng}, @file{dvisvgm}
+or @file{convert} installed@footnote{These are respectively available at
+@url{http://sourceforge.net/projects/dvipng/}, @url{http://dvisvgm.bplaced.net/}
+and from the @file{imagemagick} suite.  Choose the converter by setting the
+variable @code{org-latex-create-formula-image-program} accordingly.}, @LaTeX{}
 fragments can be processed to produce images of the typeset expressions to be
 used for inclusion while exporting to HTML (see @pxref{@LaTeX{} fragments}),
 or for inline previewing within Org mode.
@@ -11713,6 +11713,7 @@ You could use @code{http} addresses just as well.
 @subsection Math formatting in HTML export
 @cindex MathJax
 @cindex dvipng
+@cindex dvisvgm
 @cindex imagemagick
 
 @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two
@@ -11737,13 +11738,18 @@ template can be configure via @code{org-html-mathjax-template}.
 If you prefer, you can also request that @LaTeX{} fragments are processed
 into small images that will be inserted into the browser page.  Before the
 availability of MathJax, this was the default method for Org files.  This
-method