Finally, while display equations look good for a page of samples, the
86 | ability to mix math and text in a paragraph is also important. This
87 | expression $\sqrt{3x-1}+(1+x)^2$ is an example of an inline equation. As
88 | you see, MathJax equations can be used this way as well, without unduly
89 | disturbing the spacing between lines.
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/archive/beta.3/tex2html/mj3-tex2html-beta.js:
--------------------------------------------------------------------------------
1 | /*************************************************************************
2 | *
3 | * mj3-tex2html-beta.js
4 | *
5 | * Uses MathJax v3 to convert TeX to HTML within the browser.
6 | *
7 | * ----------------------------------------------------------------------
8 | *
9 | * Copyright (c) 2018 The MathJax Consortium
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | */
23 |
24 | //
25 | // Load the desired components
26 | //
27 | const MathJax = require('mathjax3/mathjax3/mathjax.js').MathJax // MathJax core
28 | const TeX = require('mathjax3/mathjax3/input/tex.js').TeX; // TeX input
29 | const CHTML = require('mathjax3/mathjax3/output/chtml.js').CHTML; // HTML output
30 | const browser = require('mathjax3/mathjax3/adaptors/browserAdaptor').browserAdaptor; // browser DOM
31 |
32 | const AllPackages = require('mathjax3/mathjax3/input/tex/AllPackages').AllPackages;
33 |
34 | //
35 | // Register the HTML handler with the browser adaptor
36 | //
37 | require('mathjax3/mathjax3/handlers/html.js').RegisterHTMLHandler(browser());
38 |
39 | //
40 | // Get the input and output jax configurations from the user
41 | //
42 | const MathJaxConfig = window.MathJaxConfig || {};
43 |
44 | const texConfig = Object.assign({
45 | packages: AllPackages
46 | }, MathJaxConfig.TeX || {});
47 |
48 | const htmlConfig = Object.assign({
49 | fontURL: 'https://cdn.rawgit.com/mathjax/mathjax-v3/3.0.0-beta.3/mathjax2/css'
50 | }, MathJaxConfig.HTML || {});
51 |
52 | //
53 | // Initialize mathjax with a DOM document.
54 | //
55 | const html = MathJax.document(document, {
56 | InputJax: new TeX(texConfig),
57 | OutputJax: new CHTML(htmlConfig)
58 | });
59 |
60 | //
61 | // The global MathJax object
62 | //
63 | window.MathJax = {
64 | version: MathJax.version,
65 | html: html,
66 |
67 | //
68 | // Process the document
69 | //
70 | Typeset: function(...elements) {
71 | this.html.findMath(elements.length ? {elements} : {})
72 | .compile()
73 | .getMetrics()
74 | .typeset()
75 | .updateDocument()
76 | .clear();
77 | }
78 | }
79 |
80 | //
81 | // Do the initial typesetting
82 | //
83 | if (!MathJaxConfig.skipInitialTypeset) {
84 | //
85 | // If the window is already loaded, just call Typeset()
86 | // Otherwise, set an event listener and run Typeset() when DOM is loaded
87 | //
88 | if (document.readyState && document.readyState !== 'loading') {
89 | window.MathJax.Typeset(...(MathJaxConfig.elements || []));
90 | } else {
91 | window.addEventListener('DOMContentLoaded',
92 | () => window.MathJax.Typeset(...(MathJaxConfig.elements || [])), false);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/archive/beta.3/tex2html/mj3-tex2html-global.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Testing MathJax v3 with interactive TeX input and HTML output
8 |
9 |
10 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/archive/beta.3/tex2html/mj3-tex2html-global.js:
--------------------------------------------------------------------------------
1 | /*************************************************************************
2 | *
3 | * mj3-tex2html-global.js
4 | *
5 | * Uses MathJax v3 to convert a TeX expression to an HTML tree.
6 | *
7 | * ----------------------------------------------------------------------
8 | *
9 | * Copyright (c) 2018 The MathJax Consortium
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | */
23 |
24 | import {TeX} from 'mathjax3/mathjax3/input/tex.js';
25 | import {CHTML} from 'mathjax3/mathjax3/output/chtml.js';
26 | import {HTMLMathItem} from 'mathjax3/mathjax3/handlers/html/HTMLMathItem.js';
27 | import {HTMLDocument} from 'mathjax3/mathjax3/handlers/html/HTMLDocument.js';
28 | import {browserAdaptor} from 'mathjax3/mathjax3/adaptors/browserAdaptor.js';
29 |
30 | import {AllPackages} from 'mathjax3/mathjax3/input/tex/AllPackages.js';
31 |
32 | //
33 | // Create the input and output jax
34 | //
35 | const tex = new TeX({
36 | packages: AllPackages
37 | });
38 | const chtml = new CHTML({
39 | fontURL: 'https://cdn.rawgit.com/mathjax/mathjax-v3/3.0.0-beta.3/mathjax2/css'
40 | });
41 |
42 | //
43 | // Make a new HTML Math Document for the browser document
44 | //
45 | const doc = new HTMLDocument(document, browserAdaptor(), {InputJax: tex, OutputJax: chtml});
46 |
47 | //
48 | // The MathJax object
49 | //
50 | window.MathJax = {
51 | //
52 | // Return the stylesheet DOM node
53 | //
54 | Stylesheet: function () {
55 | return chtml.styleSheet(doc);
56 | },
57 |
58 | //
59 | // Typeset a MathML expression and return the HTML tree for it
60 | //
61 | Typeset: function(string, display, em = 16, ex = 8, cwidth = 80*16) {
62 | let math = new HTMLMathItem(string, tex, display);
63 | math.setMetrics(em, ex, cwidth, 100000, 1);
64 | math.compile(doc);
65 | math.typeset(doc)
66 | return math.typesetRoot;
67 | },
68 |
69 | //
70 | // Reset tags and labels
71 | //
72 | Reset: function (n) {
73 | if (n) {n--} else {n = 0}
74 | tex.parseOptions.tags.reset(n);
75 | }
76 | };
77 |
--------------------------------------------------------------------------------
/archive/beta.3/tex2html/mj3-tex2html-simple.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Testing MathJax v3 with TeX input and HTML output
7 |
8 |
9 |
10 |
11 |
12 |
MathJax v3 beta: TeX input, HTML output test
13 |
14 |
15 | When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
16 | $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
17 |
Finally, while display equations look good for a page of samples, the
81 | ability to mix math and text in a paragraph is also important. This
82 | expression \(\sqrt{3x-1}+(1+x)^2\) is an example of an inline equation. As
83 | you see, MathJax equations can be used this way as well, without unduly
84 | disturbing the spacing between lines.
85 |
86 |
87 |
--------------------------------------------------------------------------------
/archive/beta.3/tex2html/mj3-tex2html-simple.js:
--------------------------------------------------------------------------------
1 | /*************************************************************************
2 | *
3 | * mj3-tex2html.js
4 | *
5 | * Uses MathJax v3 to convert TeX to HTML within a browser.
6 | *
7 | * ----------------------------------------------------------------------
8 | *
9 | * Copyright (c) 2018 The MathJax Consortium
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | */
23 |
24 | //
25 | // Load the desired components
26 | //
27 | const MathJax = require('mathjax3/mathjax3/mathjax.js').MathJax // MathJax core
28 | const TeX = require('mathjax3/mathjax3/input/tex.js').TeX; // TeX input
29 | const CHTML = require('mathjax3/mathjax3/output/chtml.js').CHTML; // HTML output
30 | const browser = require('mathjax3/mathjax3/adaptors/browserAdaptor').browserAdaptor; // browser DOM
31 |
32 | const AllPackages = require('mathjax3/mathjax3/input/tex/AllPackages.js').AllPackages;
33 |
34 | //
35 | // Register the HTML handler with the browser adaptor
36 | //
37 | require('mathjax3/mathjax3/handlers/html.js').RegisterHTMLHandler(browser());
38 |
39 | //
40 | // Initialize mathjax with a DOM document (e.g., browser, jsdom);
41 | // other documents are possible, but we use browser document here.
42 | //
43 | const html = MathJax.document(document, {
44 | InputJax: new TeX({
45 | inlineMath: [['$', '$'], ['\\(', '\\)']],
46 | packages: AllPackages
47 | }),
48 | OutputJax: new CHTML({
49 | fontURL: 'https://cdn.rawgit.com/mathjax/mathjax-v3/3.0.0-beta.3/mathjax2/css'
50 | })
51 | });
52 |
53 | //
54 | // When the page is ready...
55 | //
56 | window.addEventListener('load', () => {
57 | console.time('wrapper');
58 |
59 | //
60 | // Process the document
61 | //
62 | html.findMath()
63 | .compile()
64 | .getMetrics()
65 | .typeset()
66 | .updateDocument();
67 |
68 | console.timeEnd('wrapper');
69 | });
70 |
--------------------------------------------------------------------------------
/archive/beta.3/tex2svg/mj3-tex2svg-beta.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Testing MathJax v3 with TeX input and SVG output
7 |
8 |
13 |
14 |
15 |
16 |
17 |
MathJax v3 beta: TeX input, SVG output test
18 |
19 |
20 | When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
21 | $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
22 |
Finally, while display equations look good for a page of samples, the
86 | ability to mix math and text in a paragraph is also important. This
87 | expression $\sqrt{3x-1}+(1+x)^2$ is an example of an inline equation. As
88 | you see, MathJax equations can be used this way as well, without unduly
89 | disturbing the spacing between lines.
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/archive/beta.3/tex2svg/mj3-tex2svg-beta.js:
--------------------------------------------------------------------------------
1 | /*************************************************************************
2 | *
3 | * mj3-tex2svg-beta.js
4 | *
5 | * Uses MathJax v3 to convert TeX to SVG within the browser.
6 | *
7 | * ----------------------------------------------------------------------
8 | *
9 | * Copyright (c) 2018 The MathJax Consortium
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | */
23 |
24 | //
25 | // Load the desired components
26 | //
27 | const MathJax = require('mathjax3/mathjax3/mathjax.js').MathJax // MathJax core
28 | const TeX = require('mathjax3/mathjax3/input/tex.js').TeX; // TeX input
29 | const SVG = require('mathjax3/mathjax3/output/svg.js').SVG; // SVG output
30 | const browser = require('mathjax3/mathjax3/adaptors/browserAdaptor').browserAdaptor; // browser DOM
31 |
32 | const AllPackages = require('mathjax3/mathjax3/input/tex/AllPackages.js').AllPackages;
33 |
34 | //
35 | // Register the HTML handler with the browser adaptor
36 | //
37 | require('mathjax3/mathjax3/handlers/html.js').RegisterHTMLHandler(browser());
38 |
39 | //
40 | // Get the input and output jax configurations from the user
41 | //
42 | const MathJaxConfig = window.MathJaxConfig || {};
43 |
44 | const texConfig = Object.assign({
45 | packages: AllPackages
46 | }, MathJaxConfig.TeX || {});
47 |
48 | const svgConfig = Object.assign({}, MathJaxConfig.HTML || {});
49 |
50 | //
51 | // Initialize mathjax with a DOM document.
52 | //
53 | const html = MathJax.document(document, {
54 | InputJax: new TeX(texConfig),
55 | OutputJax: new SVG(svgConfig)
56 | });
57 |
58 | //
59 | // The global MathJax object
60 | //
61 | window.MathJax = {
62 | version: MathJax.version,
63 | html: html,
64 |
65 | //
66 | // Process the document
67 | //
68 | Typeset: function(...elements) {
69 | this.html.findMath(elements.length ? {elements} : {})
70 | .compile()
71 | .getMetrics()
72 | .typeset()
73 | .updateDocument()
74 | .clear();
75 | }
76 | }
77 |
78 | //
79 | // Do the initial typesetting
80 | //
81 | if (!MathJaxConfig.skipInitialTypeset) {
82 | //
83 | // If the window is already loaded, just call Typeset()
84 | // Otherwise, set an event listener and run Typeset() when DOM is loaded
85 | //
86 | if (document.readyState && document.readyState !== 'loading') {
87 | window.MathJax.Typeset(...(MathJaxConfig.elements || []));
88 | } else {
89 | window.addEventListener('DOMContentLoaded',
90 | () => window.MathJax.Typeset(...(MathJaxConfig.elements || [])), false);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/archive/beta.3/tex2svg/mj3-tex2svg-global.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Testing MathJax v3 with interactive TeX input and SVG output
8 |
9 |
10 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/archive/beta.3/tex2svg/mj3-tex2svg-global.js:
--------------------------------------------------------------------------------
1 | /*************************************************************************
2 | *
3 | * mj3-tex2svg-global.js
4 | *
5 | * Uses MathJax v3 to convert a TeX expression to an SVG tree.
6 | *
7 | * ----------------------------------------------------------------------
8 | *
9 | * Copyright (c) 2018 The MathJax Consortium
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | */
23 |
24 | import {TeX} from 'mathjax3/mathjax3/input/tex.js';
25 | import {SVG} from 'mathjax3/mathjax3/output/svg.js';
26 | import {HTMLMathItem} from 'mathjax3/mathjax3/handlers/html/HTMLMathItem.js';
27 | import {HTMLDocument} from 'mathjax3/mathjax3/handlers/html/HTMLDocument.js';
28 | import {browserAdaptor} from 'mathjax3/mathjax3/adaptors/browserAdaptor.js';
29 |
30 | import {AllPackages} from 'mathjax3/mathjax3/input/tex/AllPackages.js';
31 |
32 | //
33 | // Create the input and output jax
34 | //
35 | const tex = new TeX({
36 | packages: AllPackages
37 | });
38 | const svg = new SVG();
39 |
40 | //
41 | // Make a new HTML Math Document for the browser document
42 | //
43 | const doc = new HTMLDocument(document, browserAdaptor(), {InputJax: tex, OutputJax: svg});
44 |
45 | //
46 | // The MathJax object
47 | //
48 | window.MathJax = {
49 | //
50 | // Return the stylesheet DOM node
51 | //
52 | Stylesheet: function () {
53 | return svg.styleSheet(doc);
54 | },
55 |
56 | //
57 | // Typeset a MathML expression and return the SVG tree for it
58 | //
59 | Typeset: function(string, display, em = 16, ex = 8, cwidth = 80*16) {
60 | let math = new HTMLMathItem(string, tex, display);
61 | math.setMetrics(em, ex, cwidth, 100000, 1);
62 | math.compile(doc);
63 | math.typeset(doc)
64 | return math.typesetRoot;
65 | },
66 |
67 | //
68 | // Reset tags and labels
69 | //
70 | Reset: function (n) {
71 | if (n) {n--} else {n = 0}
72 | tex.parseOptions.tags.reset(n);
73 | }
74 | };
75 |
--------------------------------------------------------------------------------
/archive/beta.3/tex2svg/mj3-tex2svg-simple.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Testing MathJax v3 with TeX input and SVG output
7 |
8 |
9 |
10 |
11 |
12 |
MathJax v3 beta: TeX input, SVG output test
13 |
14 |
15 | When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
16 | $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
17 |
Finally, while display equations look good for a page of samples, the
81 | ability to mix math and text in a paragraph is also important. This
82 | expression \(\sqrt{3x-1}+(1+x)^2\) is an example of an inline equation. As
83 | you see, MathJax equations can be used this way as well, without unduly
84 | disturbing the spacing between lines.
85 |
86 |
87 |
--------------------------------------------------------------------------------
/archive/beta.3/tex2svg/mj3-tex2svg-simple.js:
--------------------------------------------------------------------------------
1 | /*************************************************************************
2 | *
3 | * mj3-tex2svg.js
4 | *
5 | * Uses MathJax v3 to convert TeX to SVG within a browser.
6 | *
7 | * ----------------------------------------------------------------------
8 | *
9 | * Copyright (c) 2018 The MathJax Consortium
10 | *
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | */
23 |
24 | //
25 | // Load the desired components
26 | //
27 | const MathJax = require('mathjax3/mathjax3/mathjax.js').MathJax // MathJax core
28 | const TeX = require('mathjax3/mathjax3/input/tex.js').TeX; // TeX input
29 | const SVG = require('mathjax3/mathjax3/output/svg.js').SVG; // SVG output
30 | const browser = require('mathjax3/mathjax3/adaptors/browserAdaptor').browserAdaptor; // browser DOM
31 |
32 | const AllPackages = require('mathjax3/mathjax3/input/tex/AllPackages.js').AllPackages;
33 |
34 | //
35 | // Register the HTML handler with the browser adaptor
36 | //
37 | require('mathjax3/mathjax3/handlers/html.js').RegisterHTMLHandler(browser());
38 |
39 | //
40 | // Initialize mathjax with a DOM document (e.g., browser, jsdom);
41 | // other documents are possible, but we use browser document here.
42 | //
43 | const html = MathJax.document(document, {
44 | InputJax: new TeX({
45 | inlineMath: [['$', '$'], ['\\(', '\\)']],
46 | packages: AllPackages
47 | }),
48 | OutputJax: new SVG()
49 | });
50 |
51 | //
52 | // When the page is ready...
53 | //
54 | window.addEventListener('load', () => {
55 | console.time('wrapper');
56 |
57 | //
58 | // Process the document
59 | //
60 | html.findMath()
61 | .compile()
62 | .getMetrics()
63 | .typeset()
64 | .updateDocument();
65 |
66 | console.timeEnd('wrapper');
67 | });
68 |
--------------------------------------------------------------------------------
/archive/beta.3/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const webpack = require('webpack');
3 | const Uglify = require('uglifyjs-webpack-plugin');
4 |
5 | const PLUGINS = function () {
6 | return [
7 | // NOTE: for minifcation
8 | new Uglify({
9 | uglifyOptions: {
10 | ie8: true
11 | }
12 | }),
13 | // NOTE: to disable asyncLoad()
14 | new webpack.NormalModuleReplacementPlugin(
15 | /AsyncLoad\.js/,
16 | function (resource) {
17 | resource.request = resource.request.replace(/AsyncLoad/,"AsyncLoad-disabled");
18 | }
19 | )
20 | ]
21 | };
22 |
23 | const MODULE = function () {
24 | return {
25 | // NOTE: for babel transpilation
26 | rules: [{
27 | test: /\.js$/,
28 | exclude: /(node_modules|bower_components)/,
29 | use: {
30 | loader: 'babel-loader',
31 | options: {
32 | presets: ['env']
33 | }
34 | }
35 | }]
36 | }
37 | };
38 |
39 | //
40 | // Create a configuration for a distribution file
41 | //
42 | const CONFIG = function (name) {
43 | const dir = __dirname + '/' + name.replace(/-.*/,'');
44 | return {
45 | name: name,
46 | entry: dir + '/mj3-' + name + '.js',
47 | output: {
48 | path: dir,
49 | filename: 'mj3-' + name + '.dist.js'
50 | },
51 | module: MODULE(),
52 | plugins: PLUGINS(),
53 | performance: {
54 | hints: false
55 | },
56 | mode: 'production'
57 | };
58 | }
59 |
60 | //
61 | // The four main configurations
62 | //
63 | const mml2htmlsimple = CONFIG('mml2html-simple');
64 | const tex2htmlsimple = CONFIG('tex2html-simple');
65 | const mml2htmlglobal = CONFIG('mml2html-global');
66 | const tex2htmlglobal = CONFIG('tex2html-global');
67 | const mml2htmlbeta = CONFIG('mml2html-beta');
68 | const tex2htmlbeta = CONFIG('tex2html-beta');
69 |
70 | const mml2svgsimple = CONFIG('mml2svg-simple');
71 | const tex2svgsimple = CONFIG('tex2svg-simple');
72 | const mml2svgglobal = CONFIG('mml2svg-global');
73 | const tex2svgglobal = CONFIG('tex2svg-global');
74 | const mml2svgbeta = CONFIG('mml2svg-beta');
75 | const tex2svgbeta = CONFIG('tex2svg-beta');
76 |
77 | //
78 | // Compile all configurations
79 | //
80 | module.exports = [
81 | mml2htmlsimple,
82 | mml2htmlglobal,
83 | mml2htmlbeta,
84 |
85 | tex2htmlsimple,
86 | tex2htmlglobal,
87 | tex2htmlbeta,
88 |
89 | mml2svgsimple,
90 | mml2svgglobal,
91 | mml2svgbeta,
92 |
93 | tex2svgsimple,
94 | tex2svgglobal,
95 | tex2svgbeta
96 | ];
97 |
98 | // OR compile one configuration, e.g.,:
99 | // module.exports = tex2html;
100 |
--------------------------------------------------------------------------------
/custom-build/custom-mathjax.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | A custom build of MathJax v3 with speech
8 |
9 |
19 |
20 |
34 |
67 |
68 |
69 |
70 |
13 | Custom combined component file with toggle included. Click on the "x"
14 | in the expression to see.
15 |
16 |
17 | $$\toggle{x}{y}{z}\endtoggle + 1$$
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/custom-component/custom-component.html.md:
--------------------------------------------------------------------------------
1 | # [custom-component.html](https://mathjax.github.io/MathJax-demos-web/custom-component/custom-component.html)
2 |
3 | This example shows how to create a component that combines several of the predefined components into one single custom component that includes exactly the pieces that you want.
4 |
5 | The main code for the component is
6 |
7 | * [custom-component.js](custom-component.js)
8 |
9 | which contains comments describing it in detail. In order to use the component in your web pages, you must turn this into a MathJax component file, which you do by first defining the component using the file
10 |
11 | * [webpack.config.js](webpack.config.js)
12 |
13 | which gives the name of the component along with some other data about directories. The final directory being set to `'.'` means that the component will be placed in the directory with the source file, but with `.min.js` as the extension rather than '.js'.
14 |
15 | To make the final component, use the commands
16 |
17 | ``` bash
18 | npm install
19 | mpn run make-custom-component
20 | ```
21 |
22 | from the main directory of this repository. That will create the `custom-component.min.js` file in the `custom-component` directory.
23 |
24 | To use this in your own web page, you only need one line:
25 |
26 | ``` html
27 |
28 | ```
29 |
30 | (include the path to the `custom-component.min.js` file if needed). You can still use a MathJax configuration in your web page, or you could put
31 |
32 | ``` javascript
33 | global.MathJax = {
34 | ...
35 | };
36 | ```
37 |
38 | before the first `require()` command in `custom-component.js` to include the configuration in the combined file itself.
39 |
40 | [Run the example](https://mathjax.github.io/MathJax-demos-web/custom-component/custom-component.html)
41 |
--------------------------------------------------------------------------------
/custom-component/custom-component.js:
--------------------------------------------------------------------------------
1 | //
2 | // Initialize the MathJax startup code
3 | //
4 | require('mathjax-full/components/src/startup/lib/startup.js');
5 |
6 | //
7 | // Get the loader module and indicate the modules that
8 | // will be loaded by hand below
9 | //
10 | const {Loader} = require('mathjax-full/js/components/loader.js');
11 | Loader.preLoad(
12 | 'loader', 'startup',
13 | 'core',
14 | 'input/tex-base',
15 | '[tex]/ams',
16 | '[tex]/newcommand',
17 | '[tex]/configmacros',
18 | '[tex]/action',
19 | 'output/chtml', 'output/chtml/fonts/tex.js',
20 | 'ui/menu'
21 | );
22 |
23 | //
24 | // Update the configuration to include any needed values
25 | // (we set the mathjax path explicitly, since it defaults
26 | // to the location from which this file is loaded)
27 | //
28 | const {insert} = require('mathjax-full/js/util/Options.js');
29 | insert(MathJax.config, {
30 | loader: {
31 | paths: {
32 | mathjax: 'https://cdn.jsdelivr.net/npm/mathjax@3/es5'
33 | }
34 | },
35 | tex: {
36 | packages: {'[+]': ['ams', 'newcommand', 'configmacros', 'action']}
37 | }
38 | }, false);
39 |
40 | //
41 | // Load the components that we want to combine into one component
42 | // (the ones listed in the preLoad() call above)
43 | //
44 | require('mathjax-full/components/src/core/core.js');
45 |
46 | require('mathjax-full/components/src/input/tex-base/tex-base.js');
47 | require('mathjax-full/components/src/input/tex/extensions/ams/ams.js');
48 | require('mathjax-full/components/src/input/tex/extensions/newcommand/newcommand.js');
49 | require('mathjax-full/components/src/input/tex/extensions/configmacros/configmacros.js');
50 | require('mathjax-full/components/src/input/tex/extensions/action/action.js');
51 |
52 | require('mathjax-full/components/src/output/chtml/chtml.js');
53 | require('mathjax-full/components/src/output/chtml/fonts/tex/tex.js');
54 |
55 | require('mathjax-full/components/src/ui/menu/menu.js');
56 |
57 | //
58 | // Loading this component will cause all the normal startup
59 | // operations to be performed when this component is loaded
60 | //
61 | require('mathjax-full/components/src/startup/startup.js');
62 |
--------------------------------------------------------------------------------
/custom-component/webpack.config.js:
--------------------------------------------------------------------------------
1 | const PACKAGE = require('mathjax-full/components/webpack.common.js');
2 |
3 | module.exports = PACKAGE(
4 | 'custom-component', // the package to build
5 | '../node_modules/mathjax-full/js', // location of the MathJax js library
6 | [], // packages to link to
7 | __dirname, // our directory
8 | '.' // dist directory
9 | );
10 |
--------------------------------------------------------------------------------
/custom-tex-extension/mml.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | MathJax v3 with custom TeX extension
8 |
19 |
20 |
21 |
22 |
23 | $$abc + \mi{abc} \mo{++} x ++ y$$
24 |
25 | $$\ms{Hello world!}$$
26 |
27 | $$\mn{\u2460\u2461\u2462}$$
28 |
29 | $$
30 | \mi[mathcolor=red]{x}
31 | \mi[mathvariant="bold"]{A}
32 | \ms[lquote="\u00AB", rquote="\u00BB"]{x}
33 | \mi[data-my-attribute="anything"]{x}
34 | $$
35 |
36 | $$\mi[bad="bad"]{x}$$
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/custom-tex-extension/mml.min.js:
--------------------------------------------------------------------------------
1 | !function(){"use strict";var t={742:function(t,a){a.VK=MathJax._.input.tex.Configuration.Configuration,MathJax._.input.tex.Configuration.ConfigurationHandler,MathJax._.input.tex.Configuration.ParserConfiguration},112:function(t,a){MathJax._.input.tex.SymbolMap.AbstractSymbolMap,MathJax._.input.tex.SymbolMap.RegExpMap,MathJax._.input.tex.SymbolMap.AbstractParseMap,MathJax._.input.tex.SymbolMap.CharacterMap,MathJax._.input.tex.SymbolMap.DelimiterMap,MathJax._.input.tex.SymbolMap.MacroMap,a.QQ=MathJax._.input.tex.SymbolMap.CommandMap,MathJax._.input.tex.SymbolMap.EnvironmentMap},438:function(t,a){a.Z=MathJax._.input.tex.TexError.default}},a={};function n(e){var r=a[e];if(void 0!==r)return r.exports;var o=a[e]={exports:{}};return t[e](o,o.exports,n),o.exports}!function(){var t=n(742),a=n(112),e=n(438);function r(t){return this.getPrevClass(t),this}function o(t){return t.replace(/\\u([0-9A-F]{4})/gi,(function(t,a){return String.fromCharCode(parseInt(a,16))}))}var i={style:!0,href:!0,id:!0,class:!0};new a.QQ("mmlMap",{mi:["mmlToken","mi"],mo:["mmlToken","mo"],mn:["mmlToken","mn"],ms:["mmlToken","ms"],mtext:["mmlToken","mtext"]},{mmlToken:function(t,a,n){var m=t.configuration.nodeFactory.mmlFactory.getNodeClass(n),u=function(t,a){var n={};if(t){for(var r;r=t.match(/^\s*((?:data-)?[a-z][-a-z]*)\s*=\s*(?:"([^"]*)"|(.*?))(?:\s+|,\s*|$)/i);){var m=r[1],u=r[2]||r[3];if(!a.defaults.hasOwnProperty(m)&&!i.hasOwnProperty(m)&&"data-"!==m.substr(0,5))throw new e.Z("BadAttribute",'Unknown attribute "%1"',m);n[m]=o(u),t=t.substr(r[0].length)}if(t.length)throw new e.Z("BadAttributeList","Can't parse as attributes: %1",t)}return n}(t.GetBrackets(a),m),s=o(t.GetArgument(a)),p=t.create("node",n,[t.create("text",s)],u);"mi"===n&&(p.setTeXclass=r),t.Push(p)}}),t.VK.create("mml",{handler:{macro:["mmlMap"]}})}()}();
--------------------------------------------------------------------------------
/custom-tex-extension/webpack.config.js:
--------------------------------------------------------------------------------
1 | const PACKAGE = require('mathjax-full/components/webpack.common.js');
2 |
3 | module.exports = PACKAGE(
4 | 'mml', // the package to build
5 | '../node_modules/mathjax-full/js', // location of the MathJax js library
6 | [ // packages to link to
7 | 'components/src/core/lib',
8 | 'components/src/input/tex-base/lib'
9 | ],
10 | __dirname, // our directory
11 | '.' // dist directory
12 | );
13 |
--------------------------------------------------------------------------------
/customized-load.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | MathJax v3 with customized list of components
8 |
22 |
23 |
24 |
25 |
26 |
27 | When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
28 | $$x = {-b \pm \sqrt{\texttip{b^2-4ac}{descriminant}} \over 2a}.$$
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/customized-load.html.md:
--------------------------------------------------------------------------------
1 | # [customized-load.html](https://mathjax.github.io/MathJax-demos-web/customized-load.html)
2 |
3 | This example shows how to mix-and-match the components that are loaded (if there isn't a combined component that includes what you need). This is done by setting the `load` array in the `loader` section of you MathJax configuration, as shown below.
4 |
5 | The key lines are
6 |
7 | ``` html
8 |
23 |
24 | ```
25 |
26 | Here, we specify the 'tex-base' input jax (which is TeX with no extra packages included), and explicitly load the `newcommand` and `action` extensions. We also load the `chtml` output jax, and the `explorer` assistive technology module.
27 |
28 | The TeX configuration registers the loaded packages with the TeX input jax (it is possible to load extensions without initially enabling them).
29 |
30 | The expression in the `\texttip` macro from the `action` module to add a tool-tip to part of the quadratic equation; hover the mouse over the discriminant to see.
31 |
32 | [Run the example](https://mathjax.github.io/MathJax-demos-web/customized-load.html)
33 |
--------------------------------------------------------------------------------
/equation-numbers.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Testing MathJax v3 Equation Numbering
8 |
15 |
16 |
25 |
26 |
27 |
28 |
137 |
138 |
139 |
140 |
--------------------------------------------------------------------------------
/equation-numbers.html.md:
--------------------------------------------------------------------------------
1 | # [equation-numbers.html](https://mathjax.github.io/MathJax-demos-web/equation-numbers.html)
2 |
3 | This example shows how to use the `tex-chtml` component to process a complete HTML page containing TeX notation with automatic equation numbers.
4 |
5 | The key lines are
6 |
7 | ``` html
8 |
15 |
16 | ```
17 |
18 | which configures the TeX input jax to include automatic tags for equations in AMS environments that call for them. The math on the page includes examples of starred environments (that tells MathJax not to number those equations), and of the use of `\notag` to prevent a tag on an equation, and `\tag{}` to override the default tag number.
19 |
20 | [Run the example](https://mathjax.github.io/MathJax-demos-web/equation-numbers.html)
21 |
--------------------------------------------------------------------------------
/equation-refs.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Testing MathJax v3 Equation Numbering
8 |
15 |
16 |
25 |
26 |
27 |
28 |
29 |
30 |
A test of Equation References
31 |
32 |
33 |
34 | Here is a labeled equation:
35 | $$x+1\over\sqrt{1-x^2}\label{ref1}$$
36 | with a reference to ref1: \ref{ref1},
37 | and another numbered one with no label:
38 | $$x+1\over\sqrt{1-x^2}$$
39 | This one uses \nonumber:
40 | $$x+1\over\sqrt{1-x^2}\nonumber$$
41 |
42 |
43 |
44 | Here's one using the equation environment:
45 | \begin{equation}
46 | x+1\over\sqrt{1-x^2}
47 | \end{equation}
48 | and one with equation* environment:
49 | \begin{equation*}
50 | x+1\over\sqrt{1-x^2}
51 | \end{equation*}
52 |
53 |
54 |
55 | This is a forward reference [\ref{ref2}] and another \eqref{ref2} for the
56 | following equation:
57 | $$x+1\over\sqrt{1-x^2}\label{ref2}$$
58 | More math:
59 | $$x+1\over\sqrt{1-x^2}$$
60 | Here is a ref inside math: \(\ref{ref2}+1\) and text after it.
61 |
62 | \begin{align}
63 | x& = y_1-y_2+y_3-y_5+y_8-\dots
64 | && \text{by \eqref{ref1}}\\
65 | & = y'\circ y^* && \text{(by \eqref{ref3})}\\
66 | & = y(0) y' && \text {by Axiom 1.}
67 | \end{align}
68 |
69 | Here's a bad ref [\ref{ref4}] to a nonexistent label.
70 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/input-mml2chtml.html.md:
--------------------------------------------------------------------------------
1 | # [input-mml2chtml.html](https://mathjax.github.io/MathJax-demos-web/input-mml2chtml.html)
2 |
3 | This example shows how to use the `MathJax.mathml2chtml()` function to process user input in MathML format, producing CommonHTML output.
4 |
5 | The key lines are
6 |
7 | ``` html
8 |
9 |
29 | ```
30 |
31 | When the user presses the `Render MathML` button, the `convert()` function above runs. The comments in the code explain how the conversion process is handled. Unlike the similar TeX examples, this example uses synchronous processing, rather than a promise-based one, since there is no equivalent to the `\require` macro in MathML input to cause an extension to be dynamically loaded. That also means it is unnecessary to disable the render button, since the `convert()` function will complete before any other user interaction can table place.
32 |
33 | [Run the example](https://mathjax.github.io/MathJax-demos-web/input-mml2chtml.html)
34 |
--------------------------------------------------------------------------------
/input-mml2svg.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | MathJax v3 with interactive MathML input and SVG output
9 |
10 |
30 |
52 |
53 |
54 |
55 |
56 |
57 |
MathJax v3: MathML to SVG
58 |
59 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/input-mml2svg.html.md:
--------------------------------------------------------------------------------
1 | # [input-mml2svg.html](https://mathjax.github.io/MathJax-demos-web/input-mml2svg.html)
2 |
3 | This example shows how to use the `MathJax.mathml2svg()` function to process user input in MathML format, producing SVG output.
4 |
5 | The key lines are
6 |
7 | ``` html
8 |
9 |
29 | ```
30 |
31 | When the user presses the `Render MathML` button, the `convert()` function above runs. The comments in the code explain how the conversion process is handled. Unlike the similar TeX examples, this example uses synchronous processing, rather than a promise-based one, since there is no equivalent to the `\require` macro in MathML input to cause an extension to be dynamically loaded. That also means it is unnecessary to disable the render button, since the `convert()` function will complete before any other user interaction can take place.
32 |
33 | [Run the example](https://mathjax.github.io/MathJax-demos-web/input-mml2svg.html)
34 |
--------------------------------------------------------------------------------
/input-tex2chtml.html.md:
--------------------------------------------------------------------------------
1 | # [input-tex2chtml.html](https://mathjax.github.io/MathJax-demos-web/input-tex2chtml.html)
2 |
3 | This example shows how to use the `MathJax.tex2chtmlPromise()` function to process user input, allowing for the possibility that they use `\require` to load extensions dynamically, or one is loaded automatically by the `autoload` extension.
4 |
5 | The key lines are
6 |
7 | ``` html
8 |
9 |
57 | ```
58 |
59 | When the user presses the `Render TeX` button or switches the `display` checkbox, the `convert()` function above runs. The comments in the code explain how the conversion process is handled. Note that the user interface is disabled during the typesetting process, since the conversion is done asynchronously in this example. This prevents the user from starting a new typeset operation while one is already in progress.
60 |
61 | [Run the example](https://mathjax.github.io/MathJax-demos-web/input-tex2chtml.html)
62 |
--------------------------------------------------------------------------------
/input-tex2mml.html.md:
--------------------------------------------------------------------------------
1 | # [input-tex2mml.html](https://mathjax.github.io/MathJax-demos-web/input-tex2mml.html)
2 |
3 | This example shows how to use the `MathJax.tex2mmlPromise()` function to process user input, allowing for the possibility that they use `\require` to load extensions dynamically, or one is loaded automatically by the `autoload` extension.
4 |
5 | The key lines are
6 |
7 | ``` html
8 |
9 |
51 | ```
52 |
53 | When the user presses the `Convert TeX` button or switches the `display` checkbox, the `convert()` function above runs. The comments in the code explain how the conversion process is handled. Note that the user interface is disabled during the conversion process, since the conversion is done asynchronously in this example. This prevents the user from starting a new conversion operation while one is already in progress.
54 |
55 | [Run the example](https://mathjax.github.io/MathJax-demos-web/input-tex2mml.html)
56 |
--------------------------------------------------------------------------------
/input-tex2svg.html.md:
--------------------------------------------------------------------------------
1 | # [input-tex2svg.html](https://mathjax.github.io/MathJax-demos-web/input-tex2svg.html)
2 |
3 | This example shows how to use the `MathJax.tex2svgPromise()` function to process user input, allowing for the possibility that they use `\require` to load extensions dynamically, or one is loaded automatically by the `autoload` extension.
4 |
5 | The key lines are
6 |
7 | ``` html
8 |
9 |
57 | ```
58 |
59 | When the user presses the `Render TeX` button or switches the `display` checkbox, the `convert()` function above runs. The comments in the code explain how the conversion process is handled. Note that the user interface is disabled during the typesetting process, since the conversion is done asynchronously in this example. This prevents the user from starting a new typeset operation while one is already in progress.
60 |
61 | [Run the example](https://mathjax.github.io/MathJax-demos-web/input-tex2svg.html)
62 |
--------------------------------------------------------------------------------
/input-tex_mml2chtml.html.md:
--------------------------------------------------------------------------------
1 | # [input-tex_mml2chtml.html](https://mathjax.github.io/MathJax-demos-web/input-tex_mml2chtml.html)
2 |
3 | This example shows how to use the `MathJax.TypesetPromise()` function to process user input that is HTML containing delimited TeX expressions and/or MathML tags, allowing for the possibility that the TeX expressions use `\require` to load extensions dynamically, or one is loaded automatically by the `autoload` extension. The resulting page will have math in CommonHTML format.
4 |
5 | The key lines are
6 |
7 | ``` html
8 |
19 |
20 |
60 | ```
61 |
62 | When the user presses the `Render HTML` button, the `convert()` function above runs. The comments in the code explain how the conversion process is handled. Note that the user interface is disabled during the typesetting process, since the conversion is done asynchronously in this example. This prevents the user from starting a new typeset operation while one is already in progress.
63 |
64 | The MathJax configuration shows how you can perform an action once MathJax is loaded and ready to run by setting the `ready()` function in the `startup` configuration block. In this case, the function does the default ready actions and then enables the render button (which is disabled by default in the HTML that creates the button). This gives you a user interface that can't be used until MathJax is actually ready to respond.
65 |
66 | [Run the example](https://mathjax.github.io/MathJax-demos-web/input-tex_mml2chtml.html)
67 |
--------------------------------------------------------------------------------
/load-mathjax/load-mathjax.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | MathJax v3 loaded only if there is math
8 |
9 |
10 |
11 |
12 | This is math: $x+1\over x-1$
13 |
14 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/load-mathjax/load-mathjax.html.md:
--------------------------------------------------------------------------------
1 | # [load-mathjax.html](https://mathjax.github.io/MathJax-demos-web/load-mathjax.html)
2 |
3 | This example shows how to load MathJax only when there is actual math in the page, and no load MathJax otherwise. This could be used, for example, in the common header for a collection of pages, say ones that are generated by a wiki or blog system. That way, pages without math will not require the download of MathJax's code and font information.
4 |
5 | This uses a script file `load-mathjax.js` containing the following:
6 |
7 | ``` javascript
8 | (function () {
9 | if (document.body.querySelector('math') ||
10 | document.body.textContent.match(/(?:\$|\\\(|\\\[|\\begin\{.*?})/)) {
11 | if (!window.MathJax) {
12 | window.MathJax = {
13 | tex: {
14 | inlineMath: {'[+]': [['$', '$']]}
15 | }
16 | };
17 | }
18 | var script = document.createElement('script');
19 | script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js';
20 | document.head.appendChild(script);
21 | }
22 | })();
23 | ```
24 |
25 | This checks the page for either the presence of `