Skip to content

Commit

Permalink
Bring README in line with MathJax/README
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc committed May 4, 2020
1 parent 6086219 commit 981a4f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ If you are loading MathJax from a CDN into a web page, there is no
need to install anything. Simply use a `script` tag that loads
MathJax from the CDN. E.g.,

```html
``` html
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
```

Expand All @@ -62,44 +62,48 @@ and the [MathJax Component
Repository](https://github.com/mathjax/MathJax-demos-web) for more information.




### Using MathJax Components in node applications

To use MathJax components in a node application, install the `mathjax` package:

npm install mathjax@3
``` bash
npm install mathjax@3
```

(we are still making updates to version 2, so you should include `@3` since the latest chronological version may not be version 3).
(we are still making updates to version 2, so you should include `@3`
since the latest chronological version may not be version 3).

Then require `mathjax` within your application:

```js
``` javascript
require('mathjax').init({ ... }).then((MathJax) => { ... });
```

where the first `{ ... }` is a MathJax configuration, and the second
`{ ... }` is the code to run after MathJax has been loaded. E.g.

```js
``` javascript
require('mathjax').init({
loader: {
require: require,
paths: {mathjax: 'mathjax/es5'},
load: ['input/tex', 'output/svg']
}
loader: {load: ['input/tex', 'output/svg']}
}).then((MathJax) => {
const svg = MathJax.tex2svg('\\frac{1}{x^2-1}', {display: true});
console.log(MathJax.startup.adaptor.outerHTML(svg));
}).catch((err) => console.log(err.message));
```

**Note:** this technique is for node-based application only, not for
browser applications. This method sets up an alternative DOM
implementation, which you don't need in the browser, and tells MathJax
to use node's `require()` command to load external modules. This
setup will not work properly in the browser, even if you webpack it or
bundle it in other ways.

See the
[documentation](https//docs.mathjax.org/en/latest/index.html#server-nodejs)
and the [MathJax Node
Repository](https://github.com/mathjax/MathJax-demos-node) for more details.


### Using MathJax modules directly in node applications

You can use the MathJax JavaScript files (as opposed to MathJax
Expand All @@ -124,7 +128,7 @@ demos](https://github.com/mathjax/MathJax-demos-node) for examples).

If you want to work from the GitHub repository directly, then do the following:

```bash
``` bash
git clone https://github.com/mathjax/MathJax-src.git mathjax-src
cd mathjax-src
npm run --silent compile
Expand Down
4 changes: 3 additions & 1 deletion components/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const PACKAGE = function (name, mathjax, libs, dir, dist) {
path: distDir,
filename: name + (dist === '.' ? '.min.js' : '.js')
},
devtool: 'sourcemap',
plugins: PLUGINS(mathjax, libs, dir),
module: MODULE(dir),
performance: {
Expand All @@ -150,8 +151,9 @@ const PACKAGE = function (name, mathjax, libs, dir, dist) {
uglifyOptions: {
output: {
ascii_only: true
},
}
},
sourceMap: true
})]
},
mode: 'production'
Expand Down

0 comments on commit 981a4f7

Please sign in to comment.