Skip to content

Commit

Permalink
Merge pull request #397 from mathjax/develop
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
dpvc authored Mar 20, 2018
2 parents 4b29b9a + e953e7a commit a3c7182
Show file tree
Hide file tree
Showing 12 changed files with 338 additions and 249 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ npm install mathjax-node
to install mathjax-node and its dependencies.

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

## Getting started

Expand Down Expand Up @@ -63,6 +63,7 @@ The `config` method is used to set _global_ configuration options. Its default o
undefinedCharError: false, // determines whether "unknown characters" (i.e., no glyph in the configured fonts) are saved in the error array
extensions: '', // a convenience option to add MathJax extensions
fontURL: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/fonts/HTML-CSS', // for webfont urls in the CSS for HTML output
paths: {}, // configures custom path variables (e.g., for third party extensions, cf. test/config-third-party-extensions.js)
MathJax: { } // standard MathJax configuration options, see https://docs.mathjax.org for more detail.
}
```
Expand Down
27 changes: 18 additions & 9 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ 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 paths = {}; // additional paths (for third party extensions)
var fontURL = ''; // location of web fonts for CHTML

var defaults = {
Expand Down Expand Up @@ -156,6 +157,11 @@ function ConfigureMathJax() {
AuthorInit: function () {
MathJax = window.MathJax;

// Add custom paths to configuration
for (let key in paths) {
MathJax.Ajax.config.path[key] = paths[key];
}

delete MathJax.Hub.config.styles; // don't need any styles
MathJax.Hub.Startup.MenuZoom = function () {}; // don't load menu or zoom code
MathJax.Extension.MathEvents = {
Expand Down Expand Up @@ -324,7 +330,7 @@ function ConfigureMathJax() {
this.d = this.D = (bbox.height + bbox.y)*scale;
}
});

//
// Don't have mglyph load images
//
Expand Down Expand Up @@ -480,14 +486,16 @@ function ConfigureMathJax() {
//
// Set up None output jax (for when only MathML output is needed)
//
MathJax.OutputJax.None = MathJax.OutputJax({
id: "None",
preTranslate: function () {},
Translate: function () {},
postTranslate: function () {}
MathJax.Hub.Register.StartupHook("End Jax", function () {
MathJax.OutputJax.None = MathJax.OutputJax({
id: "None",
preTranslate: function () {},
Translate: function () {},
postTranslate: function () {}
});
MathJax.OutputJax.None.loadComplete("jax.js");
MathJax.OutputJax.None.Register("jax/mml");
});
MathJax.OutputJax.None.loadComplete("jax.js");
MathJax.OutputJax.None.Register("jax/mml");

//
// Reset the color extension after `autoload-all`
Expand Down Expand Up @@ -515,7 +523,7 @@ function ConfigureMathJax() {
});
}
};

if (extensions) {
//
// Parse added extensions list and add to standard ones
Expand Down Expand Up @@ -958,6 +966,7 @@ exports.config = function (config) {
if (config.displayErrors != null) {displayErrors = config.displayErrors}
if (config.undefinedCharError != null) {undefinedChar = config.undefinedCharError}
if (config.extensions != null) {extensions = config.extensions}
if (config.paths != null) {paths = config.paths}
if (config.fontURL != null) {fontURL = config.fontURL}
if (config.MathJax) {
// strip MathJax config blocks to avoid errors
Expand Down
Loading

0 comments on commit a3c7182

Please sign in to comment.