You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository contains files that provide APIs to call MathJax from
4
4
node.js programs. There is an API for converting individual math
@@ -23,3 +23,55 @@ These API's can produce PNG images, but that requires the
23
23
should be installed in the `batik` directory. See the README file in that
24
24
directory for more details.
25
25
26
+
# Getting started
27
+
28
+
MahJax-node provides two libraries, `lib/mj-single.js` and `lib/mj-page.js`. Below are two very minimal examples -- be sure to check out the examples in `./bin/` for more advanced configurations.
29
+
30
+
*`lib/mj-single.js` is optimized for processing single equations.
31
+
32
+
33
+
```javascript
34
+
// a simple TeX-input example
35
+
var mjAPI =require("./lib/mj-single.js");
36
+
mjAPI.config({
37
+
MathJax: {
38
+
// traditional MathJax configuration
39
+
}
40
+
});
41
+
mjAPI.start();
42
+
43
+
var yourMath ='E = mc^2';
44
+
45
+
mjAPI.typeset({
46
+
math: yourMath,
47
+
format:"TeX", // "inline-TeX", "MathML"
48
+
mml:true, // svg:true,
49
+
}, function (data) {
50
+
if (!data.errors) {console.log(data.mml)}
51
+
});
52
+
```
53
+
54
+
55
+
*`lib/mj-page.js` is optimized for handling full HTML pages.
56
+
57
+
58
+
```javascript
59
+
var mjAPI =require("./lib/mj-page.js");
60
+
var jsdom =require("jsdom").jsdom;
61
+
62
+
vardocument=jsdom("<!DOCTYPE html><html lang='en'><head><title>Test</title></head><body><h1>Let's test mj-page</h1> <p> \\[f: X \\to Y\\], where \\( X = 2^{\mathbb{N}}\\) </p></body></html>");
0 commit comments