Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bin/am2mml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ var argv = require("yargs")
semantics: {
boolean: true,
describe: "add AsciiMath code in <semantics> tag"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;
Expand All @@ -52,7 +56,8 @@ mjAPI.config({
menuSettings: {
semantics: argv.semantics
}
}
},
extensions: argv.extensions
});
mjAPI.start();

Expand Down
6 changes: 5 additions & 1 deletion bin/am2png
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ var argv = require("yargs")
width: {
default: 100,
describe: "width of container in ex"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;

if (argv.font === "STIX") argv.font = "STIX-Web";
mjAPI.config({MathJax: {SVG: {font: argv.font}}});
mjAPI.config({MathJax: {SVG: {font: argv.font}}, extensions: argv.extensions});
mjAPI.start();

if (argv.dpi === 0) {argv.dpi = argv.ex * 16} // pixels properly sized
Expand Down
6 changes: 5 additions & 1 deletion bin/am2svg
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ var argv = require("yargs")
width: {
default: 100,
describe: "width of container in ex"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;

if (argv.font === "STIX") argv.font = "STIX-Web";
mjAPI.config({MathJax: {SVG: {font: argv.font}}});
mjAPI.config({MathJax: {SVG: {font: argv.font}}, extensions: argv.extensions});
mjAPI.start();

mjAPI.typeset({
Expand Down
6 changes: 5 additions & 1 deletion bin/mml2mml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ var argv = require("yargs")
speechstyle: {
default: "default",
describe: "style to use for speech text (default, brief, sbrief)"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;

mjAPI.config({});
mjAPI.config({extensions: argv.extensions});
mjAPI.start();

mjAPI.typeset({
Expand Down
6 changes: 5 additions & 1 deletion bin/mml2png
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ var argv = require("yargs")
width: {
default: 100,
describe: "width of container in ex"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;

if (argv.font === "STIX") argv.font = "STIX-Web";
mjAPI.config({MathJax: {SVG: {font: argv.font}}});
mjAPI.config({MathJax: {SVG: {font: argv.font}}, extensions: argv.extensions});
mjAPI.start();

if (argv.dpi === 0) {argv.dpi = argv.ex * 16} // pixels properly sized
Expand Down
6 changes: 5 additions & 1 deletion bin/mml2svg
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@ var argv = require("yargs")
width: {
default: 100,
describe: "width of container in ex"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;

if (argv.font === "STIX") argv.font = "STIX-Web";
mjAPI.config({MathJax: {SVG: {font: argv.font}}});
mjAPI.config({MathJax: {SVG: {font: argv.font}}, extensions: argv.extensions});
mjAPI.start();

mjAPI.typeset({
Expand Down
6 changes: 5 additions & 1 deletion bin/mml2svg-html5
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ var argv = require("yargs")
width: {
default: 100,
describe: "width of container in ex"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;

if (argv.font === "STIX") argv.font = "STIX-Web";
mjAPI.config({MathJax: {SVG: {font: argv.font}}});
mjAPI.config({MathJax: {SVG: {font: argv.font}}, extensions: argv.extensions});
mjAPI.start();

//
Expand Down
6 changes: 5 additions & 1 deletion bin/page2mml
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,17 @@ var argv = require("yargs")
width: {
default: 100,
describe: "width of container in ex"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;

argv.format = argv.format.split(/ *, */);

mjAPI.config({MathJax: {menuSettings: {semantics: argv.semantics}}});
mjAPI.config({MathJax: {menuSettings: {semantics: argv.semantics}}, extensions: argv.extensions});
mjAPI.start();

//
Expand Down
6 changes: 5 additions & 1 deletion bin/page2png
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,17 @@ var argv = require("yargs")
width: {
default: 100,
describe: "width of container in ex"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;

argv.format = argv.format.split(/ *, */);
if (argv.font === "STIX") argv.font = "STIX-Web";
mjAPI.config({MathJax: {SVG: {font: argv.font}}});
mjAPI.config({MathJax: {SVG: {font: argv.font}}, extensions: argv.extensions});
mjAPI.start();

if (argv.dpi === 0) {argv.dpi = argv.ex * 16} // pixels properly sized
Expand Down
6 changes: 5 additions & 1 deletion bin/page2svg
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,17 @@ var argv = require("yargs")
width: {
default: 100,
describe: "width of container in ex"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;

argv.format = argv.format.split(/ *, */);
if (argv.font === "STIX") argv.font = "STIX-Web";
mjAPI.config({MathJax: {SVG: {font: argv.font}}});
mjAPI.config({MathJax: {SVG: {font: argv.font}}, extensions: argv.extensions});
mjAPI.start();

//
Expand Down
7 changes: 6 additions & 1 deletion bin/tex2mml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ var argv = require("yargs")
notexhints: {
boolean: true,
describe: "don't add TeX-specific classes"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;
Expand All @@ -61,7 +65,8 @@ mjAPI.config({
semantics: argv.semantics,
texHints: !argv.notexhints
}
}
},
extensions: argv.extensions
});
mjAPI.start();

Expand Down
6 changes: 5 additions & 1 deletion bin/tex2png
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ var argv = require("yargs")
width: {
default: 100,
describe: "width of container in ex"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;

if (argv.font === "STIX") argv.font = "STIX-Web";
mjAPI.config({MathJax: {SVG: {font: argv.font}}});
mjAPI.config({MathJax: {SVG: {font: argv.font}}, extensions: argv.extensions});
mjAPI.start();

if (argv.dpi === 0) {argv.dpi = argv.ex * 16} // pixels properly sized
Expand Down
6 changes: 5 additions & 1 deletion bin/tex2svg
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ var argv = require("yargs")
width: {
default: 100,
describe: "width of container in ex"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;

if (argv.font === "STIX") argv.font = "STIX-Web";
mjAPI.config({MathJax: {SVG: {font: argv.font}}});
mjAPI.config({MathJax: {SVG: {font: argv.font}}, extensions: argv.extensions});
mjAPI.start();

mjAPI.typeset({
Expand Down
6 changes: 5 additions & 1 deletion bin/tex2svg-filter
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ var argv = require("yargs")
width: {
default: 100,
describe: "width of container in ex"
},
extensions: {
default: "",
describe: "extra MathJax extensions e.g. 'Safe,TeX/noUndefined'"
}
})
.argv;

if (argv.font === "STIX") argv.font = "STIX-Web";
mjAPI.config({MathJax: {SVG: {font: argv.font}}});
mjAPI.config({MathJax: {SVG: {font: argv.font}}, extensions: argv.extensions});
mjAPI.start();

var prefix = argv._[0]; // the file prefix
Expand Down
18 changes: 16 additions & 2 deletions lib/mj-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var speech = require('speech-rule-engine');
var displayMessages = false; // don't log Message.Set() calls
var displayErrors = true; // show error messages on the console
var undefinedChar = false; // unknown characters are not saved in the error array
var extensions = ''; // no additional extensions used

var defaults = {
ex: 6, // ex-size in pixels
Expand Down Expand Up @@ -341,6 +342,16 @@ function ConfigureMathJax() {
}
};

if (extensions) {
//
// Parse added extensions list and add to standard ones
//
var extensionList = extensions.split(/s*,\s*/);
for (var i = 0; i < extensionList.length; i++) {
var matches = extensionList[i].match(/^(.*?)(\.js)?$/);
window.MathJax.extensions.push(matches[1] + '.js');
}
}
if (MathJaxConfig) {Insert(window.MathJax,MathJaxConfig)}
}

Expand Down Expand Up @@ -797,17 +808,20 @@ exports.start = function () {RestartMathJax()}
// Configure MathJax and the API
// You can pass additional configuration options to MathJax using the
// MathJax property, and can set displayErrors and displayMessages
// that control the display of error messages
// that control the display of error messages, and extensions to add
// additional MathJax extensions to the base or to sub-categories.
//
// E.g.
// mjAPI.congif({
// mjAPI.config({
// MathJax: {SVG: {font: "STIX-Web"}},
// displayErrors: false
// extensions: 'Safe,TeX/noUndefined'
// });
//
exports.config = function (config) {
if (config.displayMessages != null) {displayMessages = config.displayMessages}
if (config.displayErrors != null) {displayErrors = config.displayErrors}
if (config.undefinedCharError != null) {undefinedChar = config.undefinedCharError}
if (config.extensions != null) {extensions = config.extensions}
if (config.MathJax) {MathJaxConfig = config.MathJax}
}
20 changes: 17 additions & 3 deletions lib/mj-single.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var speech = require('speech-rule-engine');
var displayMessages = false; // don't log Message.Set() calls
var displayErrors = true; // show error messages on the console
var undefinedChar = false; // unknown characters are not saved in the error array
var extensions = ''; // no additional extensions used

var defaults = {
ex: 6, // ex-size in pixels
Expand Down Expand Up @@ -315,6 +316,16 @@ function ConfigureMathJax() {
}
};

if (extensions) {
//
// Parse added extensions list and add to standard ones
//
var extensionList = extensions.split(/s*,\s*/);
for (var i = 0; i < extensionList.length; i++) {
var matches = extensionList[i].match(/^(.*?)(\.js)?$/);
window.MathJax.extensions.push(matches[1] + '.js');
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You go to a lot of effort here to break up the extensions into their individual categories, but that is not strictly necessary. The main extensions array can include things like "TeX/noUndefined.js", so it is OK to leave them all there. The only reason to move them to the categories is that they would only be loaded when the input jax was loaded, but MathJax-node loads all three input jax automatically, so there is really no savings for that. Might as well not introduce the added complexity of breaking up the list.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to consider allowing --extensions "TeX/noUndefined.js" as well as --extensions "TeX/noUndefined". In that case, you only want to add the .js if it isn't already there.

if (MathJaxConfig) {Insert(window.MathJax,MathJaxConfig)}
}

Expand Down Expand Up @@ -660,17 +671,20 @@ exports.start = function () {RestartMathJax()}
// Configure MathJax and the API
// You can pass additional configuration options to MathJax using the
// MathJax property, and can set displayErrors and displayMessages
// that control the display of error messages
// that control the display of error messages, and extensions to add
// additional MathJax extensions to the base or to sub-categories.
//
// E.g.
// mjAPI.congif({
// mjAPI.config({
// MathJax: {SVG: {font: "STIX-Web"}},
// displayErrors: false
// displayErrors: false,
// extensions: 'Safe,TeX/noUndefined'
// });
//
exports.config = function (config) {
if (config.displayMessages != null) {displayMessages = config.displayMessages}
if (config.displayErrors != null) {displayErrors = config.displayErrors}
if (config.undefinedCharError != null) {undefinedChar = config.undefinedCharError}
if (config.extensions != null) {extensions = config.extensions}
if (config.MathJax) {MathJaxConfig = config.MathJax}
}