Skip to content

Commit a3c7182

Browse files
authored
Merge pull request #397 from mathjax/develop
v2.1.0
2 parents 4b29b9a + e953e7a commit a3c7182

12 files changed

+338
-249
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ npm install mathjax-node
1111
to install mathjax-node and its dependencies.
1212

1313
**Note:**
14-
The current version of mathjax-node requires Node.js v6 or later, and uses jsdom version 10.
14+
The current version of mathjax-node requires Node.js v6 or later, and uses jsdom version 11.
1515

1616
## Getting started
1717

@@ -63,6 +63,7 @@ The `config` method is used to set _global_ configuration options. Its default o
6363
undefinedCharError: false, // determines whether "unknown characters" (i.e., no glyph in the configured fonts) are saved in the error array
6464
extensions: '', // a convenience option to add MathJax extensions
6565
fontURL: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/fonts/HTML-CSS', // for webfont urls in the CSS for HTML output
66+
paths: {}, // configures custom path variables (e.g., for third party extensions, cf. test/config-third-party-extensions.js)
6667
MathJax: { } // standard MathJax configuration options, see https://docs.mathjax.org for more detail.
6768
}
6869
```

lib/main.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var displayMessages = false; // don't log Message.Set() calls
4040
var displayErrors = true; // show error messages on the console
4141
var undefinedChar = false; // unknown characters are not saved in the error array
4242
var extensions = ''; // no additional extensions used
43+
var paths = {}; // additional paths (for third party extensions)
4344
var fontURL = ''; // location of web fonts for CHTML
4445

4546
var defaults = {
@@ -156,6 +157,11 @@ function ConfigureMathJax() {
156157
AuthorInit: function () {
157158
MathJax = window.MathJax;
158159

160+
// Add custom paths to configuration
161+
for (let key in paths) {
162+
MathJax.Ajax.config.path[key] = paths[key];
163+
}
164+
159165
delete MathJax.Hub.config.styles; // don't need any styles
160166
MathJax.Hub.Startup.MenuZoom = function () {}; // don't load menu or zoom code
161167
MathJax.Extension.MathEvents = {
@@ -324,7 +330,7 @@ function ConfigureMathJax() {
324330
this.d = this.D = (bbox.height + bbox.y)*scale;
325331
}
326332
});
327-
333+
328334
//
329335
// Don't have mglyph load images
330336
//
@@ -480,14 +486,16 @@ function ConfigureMathJax() {
480486
//
481487
// Set up None output jax (for when only MathML output is needed)
482488
//
483-
MathJax.OutputJax.None = MathJax.OutputJax({
484-
id: "None",
485-
preTranslate: function () {},
486-
Translate: function () {},
487-
postTranslate: function () {}
489+
MathJax.Hub.Register.StartupHook("End Jax", function () {
490+
MathJax.OutputJax.None = MathJax.OutputJax({
491+
id: "None",
492+
preTranslate: function () {},
493+
Translate: function () {},
494+
postTranslate: function () {}
495+
});
496+
MathJax.OutputJax.None.loadComplete("jax.js");
497+
MathJax.OutputJax.None.Register("jax/mml");
488498
});
489-
MathJax.OutputJax.None.loadComplete("jax.js");
490-
MathJax.OutputJax.None.Register("jax/mml");
491499

492500
//
493501
// Reset the color extension after `autoload-all`
@@ -515,7 +523,7 @@ function ConfigureMathJax() {
515523
});
516524
}
517525
};
518-
526+
519527
if (extensions) {
520528
//
521529
// Parse added extensions list and add to standard ones
@@ -958,6 +966,7 @@ exports.config = function (config) {
958966
if (config.displayErrors != null) {displayErrors = config.displayErrors}
959967
if (config.undefinedCharError != null) {undefinedChar = config.undefinedCharError}
960968
if (config.extensions != null) {extensions = config.extensions}
969+
if (config.paths != null) {paths = config.paths}
961970
if (config.fontURL != null) {fontURL = config.fontURL}
962971
if (config.MathJax) {
963972
// strip MathJax config blocks to avoid errors

0 commit comments

Comments
 (0)