@@ -51,7 +51,7 @@ If you are loading MathJax from a CDN into a web page, there is no
51
51
need to install anything. Simply use a ` script ` tag that loads
52
52
MathJax from the CDN. E.g.,
53
53
54
- ``` html
54
+ ``` html
55
55
<script id =" MathJax-script" async src =" https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" ></script >
56
56
```
57
57
@@ -62,44 +62,48 @@ and the [MathJax Component
62
62
Repository] ( https://github.com/mathjax/MathJax-demos-web ) for more information.
63
63
64
64
65
-
66
-
67
65
### Using MathJax Components in node applications
68
66
69
67
To use MathJax components in a node application, install the ` mathjax ` package:
70
68
71
- npm install mathjax@3
69
+ ``` bash
70
+ npm install mathjax@3
71
+ ```
72
72
73
- (we are still making updates to version 2, so you should include ` @3 ` since the latest chronological version may not be version 3).
73
+ (we are still making updates to version 2, so you should include ` @3 `
74
+ since the latest chronological version may not be version 3).
74
75
75
76
Then require ` mathjax ` within your application:
76
77
77
- ``` js
78
+ ``` javascript
78
79
require (' mathjax' ).init ({ ... }).then ((MathJax ) => { ... });
79
80
```
80
81
81
82
where the first ` { ... } ` is a MathJax configuration, and the second
82
83
` { ... } ` is the code to run after MathJax has been loaded. E.g.
83
84
84
- ``` js
85
+ ``` javascript
85
86
require (' mathjax' ).init ({
86
- loader: {
87
- require: require,
88
- paths: {mathjax: ' mathjax/es5' },
89
- load: [' input/tex' , ' output/svg' ]
90
- }
87
+ loader: {load: [' input/tex' , ' output/svg' ]}
91
88
}).then ((MathJax ) => {
92
89
const svg = MathJax .tex2svg (' \\ frac{1}{x^2-1}' , {display: true });
93
90
console .log (MathJax .startup .adaptor .outerHTML (svg));
94
91
}).catch ((err ) => console .log (err .message ));
95
92
```
96
93
94
+ ** Note:** this technique is for node-based application only, not for
95
+ browser applications. This method sets up an alternative DOM
96
+ implementation, which you don't need in the browser, and tells MathJax
97
+ to use node's ` require() ` command to load external modules. This
98
+ setup will not work properly in the browser, even if you webpack it or
99
+ bundle it in other ways.
97
100
98
101
See the
99
102
[ documentation] ( https//docs.mathjax.org/en/latest/index.html#server-nodejs )
100
103
and the [ MathJax Node
101
104
Repository] ( https://github.com/mathjax/MathJax-demos-node ) for more details.
102
105
106
+
103
107
### Using MathJax modules directly in node applications
104
108
105
109
You can use the MathJax JavaScript files (as opposed to MathJax
@@ -124,7 +128,7 @@ demos](https://github.com/mathjax/MathJax-demos-node) for examples).
124
128
125
129
If you want to work from the GitHub repository directly, then do the following:
126
130
127
- ``` bash
131
+ ``` bash
128
132
git clone https://github.com/mathjax/MathJax-src.git mathjax-src
129
133
cd mathjax-src
130
134
npm run --silent compile
0 commit comments