Skip to content

Commit 8d5c3c5

Browse files
committed
Update simple example to use promise-based call
1 parent fb7be54 commit 8d5c3c5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

server/main.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ Create a file named :file:`test-mathjax.mjs` containing the following:
3131
3232
import {init} from "@mathjax/src";
3333
await init({loader: {load: ['input/tex']}});
34-
console.log(MathJax.tex2mml('x+y'));
34+
const mml = (await MathJax.tex2mmlPromise('x+y'));
35+
console.log(mml);
3536
3637
then run this file from the command line using
3738

@@ -60,9 +61,8 @@ This is you first MathJax node program!
6061
6162
require("@mathjax/src").init({
6263
loader: {load: ['input/tex']}
63-
}).then(() =>
64-
console.log(MathJax.tex2mml('x+y'))
65-
);
64+
}).then(() => MathJax.tex2mmlPromise('x+y'))
65+
.then((mml) => console.log(mml));
6666
6767
then run this file using
6868

@@ -79,8 +79,10 @@ needed components and is ready to process mathematics, at which point
7979
the global :js:data:`MathJax` variable will be set up for use.
8080

8181
In the program above, we use the ``await`` command to wait for that
82-
promise to resolve, and then call :js:meth:`MathJax.tex2mml()` to
83-
convert a TeX or LaTeX expression into the corresponding MathML tree.
82+
promise to resolve, and then wait for the
83+
:js:meth:`MathJax.tex2mmlPromise()` call to convert a TeX or LaTeX
84+
expression into the corresponding MathML tree. The result is then
85+
printed.
8486

8587
Once you have initialized MathJax, you should be able to use MathJax
8688
in much the same way as you would in a browser. Note, however, that

0 commit comments

Comments
 (0)