A minimal socket server for daemonized LaTeXML processing
Just another Perl module. Use either the modern cpanm .
or the classic:
perl Makefile.PL ; make ; make test; sudo make install
Make sure that LaTeXML has been installed prior to installing this Plugin, as well as all modules reported missing by Makefile.PL.
See the casual author use pattern by the latexmlc executable of LaTeXML.
On a generic level, latexmls
takes an HTTP request and returns a JSON payload. This can be illustrated with a minimal curl example:
-
Start a server process on some available port, and specify the allowed inactivity before it automatically shuts down.
latexmls --port=43434 --expire=60
-
Initialize a new cached conversion profile, using the
cache_key
capability with a mock conversion call. Specify all configuration you would typically provide for latexml/latexmlpost here.curl http://localhost:43434 -o payload.json -d \ 'cache_key=eg&preload=article.cls&preload=texvc.sty&whatsin=math&whatsout=math&format=html5&source=literal:1'
-
Use the cached profile for real conversions.
curl http://localhost:43434 -o payload.json -d 'cache_key=eg&source=literal:\sqrt{x}>0'
Note that latexmls expects proper url encoding if you're assembling your HTTP requests by hand, e.g.
\sqrt{x}
needs to be transmitted as%5Csqrt%7Bx%7D
. This is done automatically by the curl-d
flag in the example above. -
The returned json payload (indented for readability here) for this configuration should look along the lines of:
{ "status": "No obvious problems", "log": "...Status:conversion: 0 ", "status_code": 0, "result": "<math ...</math>" }
- Authorea via the latexml-ruby wrapper, since 2017
- latexml-runner, a local harness for converting large collections, since 2021. Also offers a generic Rust wrapper.
See also the ltxmojo web showcase which uses a proper web service framework, as a potential alternative or inspiration for bundling LaTeXML into your web framework of choice.
While latexmls has been used in production settings, it is not secure standalone. At a minimum, known vulnerabilities in TeX-related I/O should be patched, e.g. using the secureio plugin for latexml.