brucemiller / LaTeXML

LaTeXML: a TeX and LaTeX to XML/HTML/ePub/MathML translator.
http://dlmf.nist.gov/LaTeXML/
Other
942 stars 101 forks source link

Using latexmls #2338

Open rrrnld opened 7 months ago

rrrnld commented 7 months ago

Hi,

I'm having some trouble understanding how I can use latexmls to speed up compilation a bit. My understanding is that it allows me to do all the --preloads once and have latexmlc communicate with it. Both latexmlc and latexmls are on my path, and this is my current invocation:

latexmlc /path/to/input.tex
        --pmml \
        --stylesheet=/path/to/LaTeXML-jats.xsl \
        --path=/path/to/some/extra/pkgs
        --preload=/path/to/custom.sty
        --preload=amsmath.sty \
        --preload=amssymb.sty \
        --preload=enumitem.sty \
        --preload=tikz.sty \
        --nodefaultresources

latexmls is not started, everything is loaded on each invocation and I don't notice any speedup even on frequent subsequent conversions. I tried changing --expire / --address / --port, starting latexmls manually, but still see the same behavior.

My use-case is making small changes to different tex file until it is converted to a JATS that looks good. I think they could benefit quite a bit from the speedup.

Am I misunderstanding something? What do I have to do to get latexmlc to do the conversions with latexmls?

Or if I want to skip latexmlc completely and manage latexmls myself -- what would the POST body look like to convert the input tex (which can potentially \include other tex files)?

dginev commented 7 months ago

Thanks for the question @heyarne . An even better place for the issue would be the latexmls repository. Then again, since latexmlc is in latexml itself, maybe the current setup is OK as well.

A positive value for the --expire option is all you should need to leverage a latexmls which is visible in the $PATH.

For example, I can check with:

``` $ which latexmls /home/deyan/perl5/bin/latexmls $ time latexmlc --expire=60 'literal:\sqrt{x}' --whatsin=math --dest=test.html --log=test.log Conversion complete: No obvious problems real 0m3.448s user 0m0.834s sys 0m0.203s $ time latexmlc --expire=60 'literal:\sqrt{x}' --whatsin=math --dest=test.html --log=test.log Conversion complete: No obvious problems real 0m1.209s user 0m0.399s sys 0m0.093s $ time latexmlc --expire=60 'literal:\sqrt{x}' --whatsin=math --dest=test.html --log=test.log Conversion complete: No obvious problems real 0m1.194s user 0m0.428s sys 0m0.077s ```

The issue is a helpful reminder to double-check latexmls with the v0.8.8 release of LaTeXML - I just updated a test case that had its XML markup move and will push a new latexmls on CPAN soon.

As to a POST request, the Example use section in the latexmls README should still have a functioning example. The key bit is to have format=jats to emit JATS, but a lot of the other details may vary (e.g. if you'd like the output archived as a ZIP and streamed back via a web service, or written to the local drive instead).