FxEditor
User guideQuickstartDeploymentAPIDesignFxTeX
APIExamplesAccessibilityFxTeXServer
DeploymentAPILaTeXRender
DeploymentAPIPlugins
CK Editor v5Tiny MCE v6BloggerAngularDeveloper GuideLicensing
How licensing worksfxTeXServer API
One operation: give it LaTeX, get MathML. There is no session, no account, nothing to configure per request and nothing kept between them — which is what makes the service safe to scale by simply adding replicas.
How to get a deployment running is on the Deployment page. This page is the interface, whichever of the three routes you took.
The request
The equation is the query string. Not a named parameter — the whole query string, the same convention LaTeXRender uses, so an existing URL can be pointed at either service without being rewritten:
curl "http://fxtex.example.com/?x^2%2B1"
By default an equation is a centred block. Prefix it with \inline for one that
sits in a line of text:
curl "http://fxtex.example.com/?%5Cinline%20x%5E2"
Escaping an equation into a URL
Percent-encoding, as usual. Three characters matter more than the rest, because they are the ones that either end a query string or disappear inside one:
| Character | Send as | Why |
|---|---|---|
+ | %2B or + | A bare + in a query string means a space. |
| space | %20 or &space; | Spaces are significant in LaTeX — \alpha b is not \alphab. |
& | %26 or & | A bare & starts the next parameter. Matrices are full of them. |
# | %23 | A bare # starts a fragment, and everything after it never leaves the browser. |
The named forms in the second column are accepted as well as the percent-encoded ones. They
exist because an equation URL is very often written into an HTML attribute, where
+ survives a round-trip through a template engine that would have mangled a
%2B.
In JavaScript, encodeURIComponent handles all four correctly:
const url = 'http://fxtex.example.com/?' + encodeURIComponent('\\begin{pmatrix}a&b\\\\c&d\\end{pmatrix}');
The response
A <math> element, ready to drop into a page:
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<msup><mi>x</mi><mn>2</mn></msup>
</math>
It is presentation MathML, and it is identical — character for character — to what fxTeX produces in the browser for the same input. The two implementations are checked against each other over a corpus of 15,367 equations before anything is committed, which is what lets you render part of a page on the server and the rest on the client without the two being told apart.
When an equation does not convert
An unrecognised command does not fail the request. The converter renders what it understood and records what it did not, so one unknown macro in a long equation costs you that macro rather than the equation. Where you read the record depends on the route:
| Linked library | Symbols::errors — a vector of the unrecognised commands, cleared at the start of every call. Empty means clean. |
| Node | A thrown error for input that cannot be parsed at all; otherwise the converted result. |
| HTTP | The converted result. Log errors at the source if you need the detail. |
This is worth wiring into your logging. The set of commands your own content uses that the converter does not yet know is a short, finite list, and it is the list we want to see.
Calling it in-process
The library surface, for the deployments that skip HTTP entirely:
| C++ | |
|---|---|
Symbols | The converter. Construct once and reuse; not thread-safe, so one per thread. |
void init() | Called once before the first conversion. |
std::string Latex2MathML(std::string) | Converts one equation, including its own front matter (\inline, font-size directives). |
bool isInline | Whether the equation asked to be inline. Readable after the call. |
std::vector<std::string> errors | Unrecognised commands from the most recent call. |
| Node | |
|---|---|
convertToMathML(latex, display?) | Converts one string and returns MathML. display defaults to false — inline. |
The Node package is the same module the browser bundle is built from, so everything documented under fxTeX is available to it. The DOM-scanning half simply has nothing to scan.
More
Deployment — getting a Node service, a linked library or a Docker stack running.
fxTeX — the same converter in the browser, for anything added after the page loads.
LaTeXRender — if you need a PNG, an SVG or a PDF rather than MathML.
CodeCogs®