Skip to content

Commit 17d2f5b

Browse files
committed
Update command-line tools to beta.3
1 parent 0c13d61 commit 17d2f5b

File tree

7 files changed

+75
-135
lines changed

7 files changed

+75
-135
lines changed

mj3-mml2html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var argv = require('yargs')
4747
describe: 'output the required CSS rather than the HTML itself'
4848
},
4949
fontURL: {
50-
default: 'https://cdn.rawgit.com/mathjax/mathjax-v3/3.0.0-beta.2/mathjax2/css',
50+
default: 'https://cdn.rawgit.com/mathjax/mathjax-v3/3.0.0-beta.3/mathjax2/css',
5151
describe: 'the URL to use for web fonts'
5252
}
5353
})
@@ -58,10 +58,8 @@ var argv = require('yargs')
5858
//
5959
const MathML = require('mathjax3/mathjax3/input/mathml.js').MathML;
6060
const CHTML = require('mathjax3/mathjax3/output/chtml.js').CHTML;
61-
const HTMLMathItem = require('mathjax3/mathjax3/handlers/html/HTMLMathItem.js').HTMLMathItem;
6261
const HTMLDocument = require('mathjax3/mathjax3/handlers/html/HTMLDocument.js').HTMLDocument;
6362
const liteAdaptor = require('mathjax3/mathjax3/adaptors/liteAdaptor.js').liteAdaptor;
64-
const LiteDocument = require('mathjax3/mathjax3/adaptors/lite/Document.js').LiteDocument;
6563

6664
//
6765
// Create the input and ouptut jax
@@ -73,15 +71,15 @@ const chtml = new CHTML({fontURL: argv.fontURL});
7371
// Create an HTML document using a LiteDocument and the input and output jax
7472
//
7573
const adaptor = liteAdaptor();
76-
const html = new HTMLDocument(new LiteDocument(), adaptor, {InputJax: mml, OutputJax: chtml});
74+
const html = new HTMLDocument('', adaptor, {InputJax: mml, OutputJax: chtml});
7775

7876
//
7977
// Typeset a MathML string and return the serialized HTML
8078
//
8179
const Typeset = (string, em = 16, ex = 8, cwidth = 80*16) => {
82-
const math = new HTMLMathItem(string, mml);
80+
const math = new html.options.MathItem(string, mml);
8381
math.setMetrics(em, ex, cwidth, 100000, 1);
84-
math.compile();
82+
math.compile(html);
8583
math.typeset(html)
8684
return adaptor.outerHTML(math.typesetRoot);
8785
};

mj3-mml2svg

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ var argv = require('yargs')
5454
//
5555
const MathML = require('mathjax3/mathjax3/input/mathml.js').MathML;
5656
const SVG = require('mathjax3/mathjax3/output/svg.js').SVG;
57-
const HTMLMathItem = require('mathjax3/mathjax3/handlers/html/HTMLMathItem.js').HTMLMathItem;
5857
const HTMLDocument = require('mathjax3/mathjax3/handlers/html/HTMLDocument.js').HTMLDocument;
5958
const liteAdaptor = require('mathjax3/mathjax3/adaptors/liteAdaptor.js').liteAdaptor;
60-
const LiteDocument = require('mathjax3/mathjax3/adaptors/lite/Document.js').LiteDocument;
6159

6260
//
6361
// Create the input and ouptut jax
@@ -69,15 +67,15 @@ const svg = new SVG();
6967
// Create an HTML document using a LiteDocument and the input and output jax
7068
//
7169
const adaptor = liteAdaptor();
72-
const html = new HTMLDocument(new LiteDocument(), adaptor, {InputJax: mml, OutputJax: svg});
70+
const html = new HTMLDocument('', adaptor, {InputJax: mml, OutputJax: svg});
7371

7472
//
7573
// Typeset a MathML string and return the serialized HTML
7674
//
7775
const Typeset = (string, em = 16, ex = 8, cwidth = 80*16) => {
78-
const math = new HTMLMathItem(string, mml);
76+
const math = new html.options.MathItem(string, mml);
7977
math.setMetrics(em, ex, cwidth, 100000, 1);
80-
math.compile();
78+
math.compile(html);
8179
math.typeset(html)
8280
return adaptor.outerHTML(math.typesetRoot);
8381
};

mj3-tex2html

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323
* limitations under the License.
2424
*/
2525

26+
//
27+
// Load the packages needed for MathJax
28+
//
29+
const TeX = require('mathjax3/mathjax3/input/tex.js').TeX;
30+
const CHTML = require('mathjax3/mathjax3/output/chtml.js').CHTML;
31+
const HTMLDocument = require('mathjax3/mathjax3/handlers/html/HTMLDocument.js').HTMLDocument;
32+
const liteAdaptor = require('mathjax3/mathjax3/adaptors/liteAdaptor.js').liteAdaptor;
33+
34+
const AllPackages = require('mathjax3/mathjax3/input/tex/AllPackages.js').AllPackages;
35+
2636
//
2737
// Get the command-line arguments
2838
//
@@ -47,42 +57,20 @@ var argv = require('yargs')
4757
describe: 'width of container in pixels'
4858
},
4959
packages: {
50-
default: 'base, ams, noundefined, newcommand, boldsymbol, braket, mhchem, physics, verb, cancel, enclose',
60+
default: AllPackages.sort().join(', '),
5161
describe: 'the packages to use, e.g. "base, ams"'
5262
},
5363
css: {
5464
boolean: true,
5565
describe: 'output the required CSS rather than the HTML itself'
5666
},
5767
fontURL: {
58-
default: 'https://cdn.rawgit.com/mathjax/mathjax-v3/3.0.0-beta.2/mathjax2/css',
68+
default: 'https://cdn.rawgit.com/mathjax/mathjax-v3/3.0.0-beta.3/mathjax2/css',
5969
describe: 'the URL to use for web fonts'
6070
}
6171
})
6272
.argv;
6373

64-
//
65-
// Load the packages needed for MathJax
66-
//
67-
const TeX = require('mathjax3/mathjax3/input/tex.js').TeX;
68-
const CHTML = require('mathjax3/mathjax3/output/chtml.js').CHTML;
69-
const HTMLMathItem = require('mathjax3/mathjax3/handlers/html/HTMLMathItem.js').HTMLMathItem;
70-
const HTMLDocument = require('mathjax3/mathjax3/handlers/html/HTMLDocument.js').HTMLDocument;
71-
const liteAdaptor = require('mathjax3/mathjax3/adaptors/liteAdaptor.js').liteAdaptor;
72-
const LiteDocument = require('mathjax3/mathjax3/adaptors/lite/Document.js').LiteDocument;
73-
74-
require('mathjax3/mathjax3/input/tex/base/BaseConfiguration.js');
75-
require('mathjax3/mathjax3/input/tex/ams/AmsConfiguration.js');
76-
require('mathjax3/mathjax3/input/tex/noundefined/NoUndefinedConfiguration.js');
77-
require('mathjax3/mathjax3/input/tex/newcommand/NewcommandConfiguration.js');
78-
require('mathjax3/mathjax3/input/tex/boldsymbol/BoldsymbolConfiguration.js');
79-
require('mathjax3/mathjax3/input/tex/braket/BraketConfiguration.js');
80-
require('mathjax3/mathjax3/input/tex/mhchem/MhchemConfiguration.js');
81-
require('mathjax3/mathjax3/input/tex/physics/PhysicsConfiguration.js');
82-
require('mathjax3/mathjax3/input/tex/verb/VerbConfiguration.js');
83-
require('mathjax3/mathjax3/input/tex/cancel/CancelConfiguration.js');
84-
require('mathjax3/mathjax3/input/tex/enclose/EncloseConfiguration.js');
85-
8674
//
8775
// Create the input and ouptut jax
8876
//
@@ -93,15 +81,15 @@ const chtml = new CHTML({fontURL: argv.fontURL});
9381
// Create an HTML document using a LiteDocument and the input and output jax
9482
//
9583
const adaptor = liteAdaptor();
96-
const html = new HTMLDocument(new LiteDocument(), adaptor, {InputJax: tex, OutputJax: chtml});
84+
const html = new HTMLDocument('', adaptor, {InputJax: tex, OutputJax: chtml});
9785

9886
//
9987
// Typeset a TeX string and return the serialized HTML
10088
//
10189
const Typeset = (string, display, em = 16, ex = 8, cwidth = 80*16) => {
102-
const math = new HTMLMathItem(string, tex, display);
90+
const math = new html.options.MathItem(string, tex, display);
10391
math.setMetrics(em, ex, cwidth, 100000, 1);
104-
math.compile();
92+
math.compile(html);
10593
math.typeset(html)
10694
return adaptor.outerHTML(math.typesetRoot);
10795
};

mj3-tex2html-page

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@
2323
* limitations under the License.
2424
*/
2525

26+
//
27+
// Load the packages needed for MathJax
28+
//
29+
const MathJax = require('mathjax3/mathjax3/mathjax.js').MathJax;
30+
const TeX = require('mathjax3/mathjax3/input/tex.js').TeX;
31+
const CHTML = require('mathjax3/mathjax3/output/chtml.js').CHTML;
32+
33+
const AllPackages = require('mathjax3/mathjax3/input/tex/AllPackages.js').AllPackages;
34+
2635
//
2736
// Get the command-line arguments
2837
//
@@ -39,37 +48,18 @@ var argv = require('yargs')
3948
describe: 'ex-size in pixels'
4049
},
4150
packages: {
42-
default: 'base, ams, noundefined, newcommand, boldsymbol, bracket, mhchem, physics, verb, cancel, enclose',
51+
default: AllPackages.sort().join(', '),
4352
describe: 'the packages to use, e.g. "base, ams"'
4453
},
4554
fontURL: {
46-
default: 'https://cdn.rawgit.com/mathjax/mathjax-v3/3.0.0-beta.2/mathjax2/css',
55+
default: 'https://cdn.rawgit.com/mathjax/mathjax-v3/3.0.0-beta.3/mathjax2/css',
4756
describe: 'the URL to use for web fonts'
4857
}
4958
})
5059
.argv;
5160

5261
const fs = require('fs');
5362

54-
//
55-
// Load the packages needed for MathJax
56-
//
57-
const MathJax = require('mathjax3/mathjax3/mathjax.js').MathJax;
58-
const TeX = require('mathjax3/mathjax3/input/tex.js').TeX;
59-
const CHTML = require('mathjax3/mathjax3/output/chtml.js').CHTML;
60-
61-
require('mathjax3/mathjax3/input/tex/base/BaseConfiguration.js');
62-
require('mathjax3/mathjax3/input/tex/ams/AmsConfiguration.js');
63-
require('mathjax3/mathjax3/input/tex/noundefined/NoUndefinedConfiguration.js');
64-
require('mathjax3/mathjax3/input/tex/newcommand/NewcommandConfiguration.js');
65-
require('mathjax3/mathjax3/input/tex/boldsymbol/BoldsymbolConfiguration.js');
66-
require('mathjax3/mathjax3/input/tex/braket/BraketConfiguration.js');
67-
require('mathjax3/mathjax3/input/tex/mhchem/MhchemConfiguration.js');
68-
require('mathjax3/mathjax3/input/tex/physics/PhysicsConfiguration.js');
69-
require('mathjax3/mathjax3/input/tex/verb/VerbConfiguration.js');
70-
require('mathjax3/mathjax3/input/tex/cancel/CancelConfiguration.js');
71-
require('mathjax3/mathjax3/input/tex/enclose/EncloseConfiguration.js');
72-
7363
//
7464
// Create DOM adaptor and register it for HTML documents
7565
//

mj3-tex2mml

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@
2323
* limitations under the License.
2424
*/
2525

26+
//
27+
// Load the packages needed for MathJax
28+
//
29+
const TeX = require('mathjax3/mathjax3/input/tex.js').TeX;
30+
const HTMLDocument = require('mathjax3/mathjax3/handlers/html/HTMLDocument.js').HTMLDocument;
31+
const liteAdaptor = require('mathjax3/mathjax3/adaptors/liteAdaptor.js').liteAdaptor;
32+
33+
const AllPackages = require('mathjax3/mathjax3/input/tex/AllPackages.js').AllPackages;
34+
2635
//
2736
// Get the command-line arguments
2837
//
@@ -35,56 +44,35 @@ var argv = require('yargs')
3544
describe: "process as display math"
3645
},
3746
packages: {
38-
default: 'base, ams, noundefined, newcommand, boldsymbol, braket, mhchem, physics, verb, cancel, enclose',
47+
default: AllPackages.sort().join(', '),
3948
describe: 'the packages to use, e.g. "base, ams"'
4049
}
4150
})
4251
.argv;
4352

4453
//
45-
// Load the packages needed for MathJax
54+
// Create the input jax
4655
//
47-
const TeX = require('mathjax3/mathjax3/input/tex.js').TeX;
48-
const AbstractMathItem = require('mathjax3/mathjax3/core/MathItem.js').AbstractMathItem;
49-
const LiteDocument = require('mathjax3/mathjax3/adaptors/lite/Document.js').LiteDocument;
50-
51-
require('mathjax3/mathjax3/input/tex/base/BaseConfiguration.js');
52-
require('mathjax3/mathjax3/input/tex/ams/AmsConfiguration.js');
53-
require('mathjax3/mathjax3/input/tex/noundefined/NoUndefinedConfiguration.js');
54-
require('mathjax3/mathjax3/input/tex/newcommand/NewcommandConfiguration.js');
55-
require('mathjax3/mathjax3/input/tex/boldsymbol/BoldsymbolConfiguration.js');
56-
require('mathjax3/mathjax3/input/tex/braket/BraketConfiguration.js');
57-
require('mathjax3/mathjax3/input/tex/mhchem/MhchemConfiguration.js');
58-
require('mathjax3/mathjax3/input/tex/physics/PhysicsConfiguration.js');
59-
require('mathjax3/mathjax3/input/tex/verb/VerbConfiguration.js');
60-
require('mathjax3/mathjax3/input/tex/cancel/CancelConfiguration.js');
61-
require('mathjax3/mathjax3/input/tex/enclose/EncloseConfiguration.js');
62-
63-
const MmlVisitor = require('mathjax3/mathjax3/core/MmlTree/SerializedMmlVisitor.js').SerializedMmlVisitor;
64-
65-
//
66-
// A generic math item
67-
//
68-
class GenericMathItem extends AbstractMathItem {};
56+
const tex = new TeX({packages: argv.packages.split(/\s*,\s*/)});
6957

7058
//
71-
// Create the input jax and document
59+
// Create an HTML document using a LiteDocument and the input jax
7260
//
73-
const tex = new TeX({packages: argv.packages.split(/\s*,\s*/)});
74-
const document = new LiteDocument();
61+
const html = new HTMLDocument('', liteAdaptor(), {InputJax: tex});
7562

7663
//
7764
// Create a MathML serializer
7865
//
66+
const MmlVisitor = require('mathjax3/mathjax3/core/MmlTree/SerializedMmlVisitor.js').SerializedMmlVisitor;
7967
const visitor = new MmlVisitor();
80-
const toMathML = (node => visitor.visitTree(node, document));
68+
const toMathML = (node => visitor.visitTree(node, html));
8169

8270
//
8371
// Typeset a TeX string and return the serialized MathML
8472
//
8573
const Typeset = (string, display) => {
86-
const math = new GenericMathItem(string, tex, display);
87-
math.compile();
74+
const math = new html.options.MathItem(string, tex, display);
75+
math.compile(html);
8876
return toMathML(math.root);
8977
};
9078

mj3-tex2svg

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323
* limitations under the License.
2424
*/
2525

26+
//
27+
// Load the packages needed for MathJax
28+
//
29+
const TeX = require('mathjax3/mathjax3/input/tex.js').TeX;
30+
const SVG = require('mathjax3/mathjax3/output/svg.js').SVG;
31+
const HTMLDocument = require('mathjax3/mathjax3/handlers/html/HTMLDocument.js').HTMLDocument;
32+
const liteAdaptor = require('mathjax3/mathjax3/adaptors/liteAdaptor.js').liteAdaptor;
33+
34+
const AllPackages = require('mathjax3/mathjax3/input/tex/AllPackages.js').AllPackages;
35+
2636
//
2737
// Get the command-line arguments
2838
//
@@ -47,7 +57,7 @@ var argv = require('yargs')
4757
describe: 'width of container in pixels'
4858
},
4959
packages: {
50-
default: 'base, ams, noundefined, newcommand, boldsymbol, braket, mhchem, physics, verb, cancel, enclose',
60+
default: AllPackages.sort().join(', '),
5161
describe: 'the packages to use, e.g. "base, ams"'
5262
},
5363
css: {
@@ -57,28 +67,6 @@ var argv = require('yargs')
5767
})
5868
.argv;
5969

60-
//
61-
// Load the packages needed for MathJax
62-
//
63-
const TeX = require('mathjax3/mathjax3/input/tex.js').TeX;
64-
const SVG = require('mathjax3/mathjax3/output/svg.js').SVG;
65-
const HTMLMathItem = require('mathjax3/mathjax3/handlers/html/HTMLMathItem.js').HTMLMathItem;
66-
const HTMLDocument = require('mathjax3/mathjax3/handlers/html/HTMLDocument.js').HTMLDocument;
67-
const liteAdaptor = require('mathjax3/mathjax3/adaptors/liteAdaptor.js').liteAdaptor;
68-
const LiteDocument = require('mathjax3/mathjax3/adaptors/lite/Document.js').LiteDocument;
69-
70-
require('mathjax3/mathjax3/input/tex/base/BaseConfiguration.js');
71-
require('mathjax3/mathjax3/input/tex/ams/AmsConfiguration.js');
72-
require('mathjax3/mathjax3/input/tex/noundefined/NoUndefinedConfiguration.js');
73-
require('mathjax3/mathjax3/input/tex/newcommand/NewcommandConfiguration.js');
74-
require('mathjax3/mathjax3/input/tex/boldsymbol/BoldsymbolConfiguration.js');
75-
require('mathjax3/mathjax3/input/tex/braket/BraketConfiguration.js');
76-
require('mathjax3/mathjax3/input/tex/mhchem/MhchemConfiguration.js');
77-
require('mathjax3/mathjax3/input/tex/physics/PhysicsConfiguration.js');
78-
require('mathjax3/mathjax3/input/tex/verb/VerbConfiguration.js');
79-
require('mathjax3/mathjax3/input/tex/cancel/CancelConfiguration.js');
80-
require('mathjax3/mathjax3/input/tex/enclose/EncloseConfiguration.js');
81-
8270
//
8371
// Create the input and ouptut jax
8472
//
@@ -89,15 +77,15 @@ const svg = new SVG();
8977
// Create an HTML document using a LiteDocument and the input and output jax
9078
//
9179
const adaptor = liteAdaptor();
92-
const html = new HTMLDocument(new LiteDocument(), adaptor, {InputJax: tex, OutputJax: svg});
80+
const html = new HTMLDocument('', adaptor, {InputJax: tex, OutputJax: svg});
9381

9482
//
9583
// Typeset a TeX string and return the serialized HTML
9684
//
9785
const Typeset = (string, display, em = 16, ex = 8, cwidth = 80*16) => {
98-
const math = new HTMLMathItem(string, tex, display);
86+
const math = new html.options.MathItem(string, tex, display);
9987
math.setMetrics(em, ex, cwidth, 100000, 1);
100-
math.compile();
88+
math.compile(html);
10189
math.typeset(html)
10290
return adaptor.outerHTML(math.typesetRoot);
10391
};

0 commit comments

Comments
 (0)