From 981a4f751f8864c7f0533fe8110b5490b96a804f Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Mon, 4 May 2020 13:27:36 -0400 Subject: [PATCH] Bring README in line with MathJax/README --- README.md | 30 +++++++++++++++++------------- components/webpack.common.js | 4 +++- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 0a2512f0d..9d4407655 100644 --- a/README.md +++ b/README.md @@ -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 ``` @@ -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 @@ -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 diff --git a/components/webpack.common.js b/components/webpack.common.js index 2ebb2e71a..4cf9fa9ef 100644 --- a/components/webpack.common.js +++ b/components/webpack.common.js @@ -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: { @@ -150,8 +151,9 @@ const PACKAGE = function (name, mathjax, libs, dir, dist) { uglifyOptions: { output: { ascii_only: true - }, + } }, + sourceMap: true })] }, mode: 'production'